Main Page | Alphabetical List | Data Structures | 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 //! Send a verbose message (based on verbose level)
00044 /*!
00045  * This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
00046  * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
00047  * This will print the message to the console if the verbose level is set to a level >= 3
00048  * Note the abscence of a comma after the VERBOSE_PREFIX_3.  This is important.
00049  * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
00050  */
00051 extern void ast_verbose(const char *fmt, ...)
00052    __attribute__ ((format (printf, 1, 2)));
00053 
00054 extern int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00055 extern int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00056 extern int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
00057 extern void ast_console_puts(const char *string);
00058 
00059 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
00060 
00061 #ifdef LOG_DEBUG
00062 #undef LOG_DEBUG
00063 #endif
00064 #define __LOG_DEBUG    0
00065 #define LOG_DEBUG      __LOG_DEBUG, _A_
00066 
00067 #ifdef LOG_EVENT
00068 #undef LOG_EVENT
00069 #endif
00070 #define __LOG_EVENT    1
00071 #define LOG_EVENT      __LOG_EVENT, _A_
00072 
00073 #ifdef LOG_NOTICE
00074 #undef LOG_NOTICE
00075 #endif
00076 #define __LOG_NOTICE   2
00077 #define LOG_NOTICE     __LOG_NOTICE, _A_
00078 
00079 #ifdef LOG_WARNING
00080 #undef LOG_WARNING
00081 #endif
00082 #define __LOG_WARNING  3
00083 #define LOG_WARNING    __LOG_WARNING, _A_
00084 
00085 #ifdef LOG_ERROR
00086 #undef LOG_ERROR
00087 #endif
00088 #define __LOG_ERROR    4
00089 #define LOG_ERROR      __LOG_ERROR, _A_
00090 
00091 #ifdef LOG_VERBOSE
00092 #undef LOG_VERBOSE
00093 #endif
00094 #define __LOG_VERBOSE  5
00095 #define LOG_VERBOSE    __LOG_VERBOSE, _A_
00096 
00097 #if defined(__cplusplus) || defined(c_plusplus)
00098 }
00099 #endif
00100 
00101 
00102 #endif

Generated on Fri Feb 27 12:19:43 2004 for Asterisk by doxygen 1.3.5