Wed Oct 28 15:47:54 2009

Asterisk developer's documentation


logger.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020   \file logger.h
00021   \brief Support for logging to various files, console and syslog
00022    Configuration in file logger.conf
00023 */
00024 
00025 #ifndef _ASTERISK_LOGGER_H
00026 #define _ASTERISK_LOGGER_H
00027 
00028 #include "asterisk/compat.h"
00029 
00030 #include <stdarg.h>
00031 
00032 #if defined(__cplusplus) || defined(c_plusplus)
00033 extern "C" {
00034 #endif
00035 
00036 #define EVENTLOG "event_log"
00037 #define  QUEUELOG "queue_log"
00038 
00039 #define DEBUG_M(a) { \
00040    a; \
00041 }
00042 
00043 /*! Used for sending a log message */
00044 /*!
00045    \brief This is the standard logger function.  Probably the only way you will invoke it would be something like this:
00046    ast_log(LOG_WHATEVER, "Problem with the %s Captain.  We should get some more.  Will %d be enough?\n", "flux capacitor", 10);
00047    where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending
00048    on which log you wish to output to. These are implemented as macros, that
00049    will provide the function with the needed arguments.
00050 
00051    \param level   Type of log event
00052    \param file Will be provided by the LOG_* macro
00053    \param line Will be provided by the LOG_* macro
00054    \param function   Will be provided by the LOG_* macro
00055    \param fmt  This is what is important.  The format is the same as your favorite breed of printf.  You know how that works, right? :-)
00056  */
00057 extern void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
00058    __attribute__ ((format (printf, 5, 6)));
00059 
00060 extern void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
00061    __attribute__ ((format (printf, 5, 6)));
00062 
00063 /*! Send a verbose message (based on verbose level) 
00064    \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
00065    ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
00066    This will print the message to the console if the verbose level is set to a level >= 3
00067    Note the abscence of a comma after the VERBOSE_PREFIX_3.  This is important.
00068    VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
00069  */
00070 extern void ast_verbose(const char *fmt, ...)
00071    __attribute__ ((format (printf, 1, 2)));
00072 
00073 extern int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00074 extern int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00075 extern int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00076 extern void ast_console_puts(const char *string);
00077 
00078 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
00079 
00080 #ifdef LOG_DEBUG
00081 #undef LOG_DEBUG
00082 #endif
00083 #define __LOG_DEBUG    0
00084 #define LOG_DEBUG      __LOG_DEBUG, _A_
00085 
00086 #ifdef LOG_EVENT
00087 #undef LOG_EVENT
00088 #endif
00089 #define __LOG_EVENT    1
00090 #define LOG_EVENT      __LOG_EVENT, _A_
00091 
00092 #ifdef LOG_NOTICE
00093 #undef LOG_NOTICE
00094 #endif
00095 #define __LOG_NOTICE   2
00096 #define LOG_NOTICE     __LOG_NOTICE, _A_
00097 
00098 #ifdef LOG_WARNING
00099 #undef LOG_WARNING
00100 #endif
00101 #define __LOG_WARNING  3
00102 #define LOG_WARNING    __LOG_WARNING, _A_
00103 
00104 #ifdef LOG_ERROR
00105 #undef LOG_ERROR
00106 #endif
00107 #define __LOG_ERROR    4
00108 #define LOG_ERROR      __LOG_ERROR, _A_
00109 
00110 #ifdef LOG_VERBOSE
00111 #undef LOG_VERBOSE
00112 #endif
00113 #define __LOG_VERBOSE  5
00114 #define LOG_VERBOSE    __LOG_VERBOSE, _A_
00115 
00116 #ifdef LOG_DTMF
00117 #undef LOG_DTMF
00118 #endif
00119 #define __LOG_DTMF  6
00120 #define LOG_DTMF    __LOG_DTMF, _A_
00121 
00122 #if defined(__cplusplus) || defined(c_plusplus)
00123 }
00124 #endif
00125 
00126 #endif /* _ASTERISK_LOGGER_H */

Generated on Wed Oct 28 15:47:54 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6