Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

logger.h

Go to the documentation of this file.
00001 /*
00002  * Cheops Next Generation
00003  * 
00004  * Mark Spencer <markster@marko.net>
00005  *
00006  * Copyright(C) Mark Spencer
00007  * 
00008  * Distributed under the terms of the GNU General Public License (GPL) Version
00009  *
00010  * Logging routines
00011  *
00012  */
00013 
00014 #ifndef _LOGGER_H
00015 #define _LOGGER_H
00016 
00017 #include <stdarg.h>
00018 
00019 #if defined(__cplusplus) || defined(c_plusplus)
00020 extern "C" {
00021 #endif
00022 
00023 #define EVENTLOG "event_log"
00024 
00025 #define DEBUG_M(a) { \
00026    a; \
00027 }
00028 
00029 //! Used for sending a log message
00030 /*!
00031  * \param level don't need to worry about it
00032  * \param file ditto
00033  * \param line ditto
00034  * \param function ditto
00035  * \param fmt this is what is important.  The format is the same as your favorite breed of printf.  You know how that works, right? :-)
00036  * This is the standard logger function.  Probably the only way you will invoke it would be something like this:
00037  * ast_log(LOG_WHATEVER, "Problem with the %s Captain.  We should get some more.  Will %d be enough?", "flux capacitor", 10);
00038  * where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to.
00039  */
00040 extern void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
00041    __attribute__ ((format (printf, 5, 6)));
00042 
00043 extern void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
00044    __attribute__ ((format (printf, 5, 6)));
00045 
00046 //! Send a verbose message (based on verbose level)
00047 /*!
00048  * This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
00049  * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
00050  * This will print the message to the console if the verbose level is set to a level >= 3
00051  * Note the abscence of a comma after the VERBOSE_PREFIX_3.  This is important.
00052  * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
00053  */
00054 extern void ast_verbose(const char *fmt, ...)
00055    __attribute__ ((format (printf, 1, 2)));
00056 
00057 extern int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00058 extern int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00059 extern int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00060 extern void ast_console_puts(const char *string);
00061 
00062 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
00063 
00064 #ifdef LOG_DEBUG
00065 #undef LOG_DEBUG
00066 #endif
00067 #define __LOG_DEBUG    0
00068 #define LOG_DEBUG      __LOG_DEBUG, _A_
00069 
00070 #ifdef LOG_EVENT
00071 #undef LOG_EVENT
00072 #endif
00073 #define __LOG_EVENT    1
00074 #define LOG_EVENT      __LOG_EVENT, _A_
00075 
00076 #ifdef LOG_NOTICE
00077 #undef LOG_NOTICE
00078 #endif
00079 #define __LOG_NOTICE   2
00080 #define LOG_NOTICE     __LOG_NOTICE, _A_
00081 
00082 #ifdef LOG_WARNING
00083 #undef LOG_WARNING
00084 #endif
00085 #define __LOG_WARNING  3
00086 #define LOG_WARNING    __LOG_WARNING, _A_
00087 
00088 #ifdef LOG_ERROR
00089 #undef LOG_ERROR
00090 #endif
00091 #define __LOG_ERROR    4
00092 #define LOG_ERROR      __LOG_ERROR, _A_
00093 
00094 #ifdef LOG_VERBOSE
00095 #undef LOG_VERBOSE
00096 #endif
00097 #define __LOG_VERBOSE  5
00098 #define LOG_VERBOSE    __LOG_VERBOSE, _A_
00099 
00100 #if defined(__cplusplus) || defined(c_plusplus)
00101 }
00102 #endif
00103 
00104 
00105 #endif

Generated on Wed Mar 16 20:08:34 2005 for Asterisk by  doxygen 1.4.0