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 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
00058 
00059 #define LOG_DEBUG 0, _A_
00060 #define LOG_EVENT   1, _A_
00061 #define LOG_NOTICE  2, _A_
00062 #define LOG_WARNING 3, _A_
00063 #define LOG_ERROR 4, _A_
00064 
00065 #if defined(__cplusplus) || defined(c_plusplus)
00066 }
00067 #endif
00068 
00069 
00070 #endif

Generated on Fri Oct 31 07:05:06 2003 for Asterisk by doxygen 1.3.4