2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 \brief Support for logging to various files, console and syslog
22 Configuration in file logger.conf
25 #ifndef _ASTERISK_LOGGER_H
26 #define _ASTERISK_LOGGER_H
28 #include "asterisk/compat.h"
32 #if defined(__cplusplus) || defined(c_plusplus)
36 #define EVENTLOG "event_log"
38 #define DEBUG_M(a) { \
42 #define VERBOSE_PREFIX_1 " "
43 #define VERBOSE_PREFIX_2 " == "
44 #define VERBOSE_PREFIX_3 " -- "
45 #define VERBOSE_PREFIX_4 " > "
47 /*! Used for sending a log message */
49 \brief This is the standard logger function. Probably the only way you will invoke it would be something like this:
50 ast_log(LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?", "flux capacitor", 10);
51 where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending
52 on which log you wish to output to. These are implemented as macros, that
53 will provide the function with the needed arguments.
55 \param level Type of log event
56 \param file Will be provided by the LOG_* macro
57 \param line Will be provided by the LOG_* macro
58 \param function Will be provided by the LOG_* macro
59 \param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
61 extern void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
62 __attribute__ ((format (printf, 5, 6)));
64 extern void ast_backtrace(void);
66 extern void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
67 __attribute__ ((format (printf, 5, 6)));
69 /*! Send a verbose message (based on verbose level)
70 \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
71 ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
72 This will print the message to the console if the verbose level is set to a level >= 3
73 Note the abscence of a comma after the VERBOSE_PREFIX_3. This is important.
74 VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
76 extern void ast_verbose(const char *fmt, ...)
77 __attribute__ ((format (printf, 1, 2)));
79 extern int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
80 extern int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
81 extern int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
82 extern void ast_console_puts(const char *string);
84 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
90 #define LOG_DEBUG __LOG_DEBUG, _A_
96 #define LOG_EVENT __LOG_EVENT, _A_
101 #define __LOG_NOTICE 2
102 #define LOG_NOTICE __LOG_NOTICE, _A_
107 #define __LOG_WARNING 3
108 #define LOG_WARNING __LOG_WARNING, _A_
113 #define __LOG_ERROR 4
114 #define LOG_ERROR __LOG_ERROR, _A_
119 #define __LOG_VERBOSE 5
120 #define LOG_VERBOSE __LOG_VERBOSE, _A_
126 #define LOG_DTMF __LOG_DTMF, _A_
128 #if defined(__cplusplus) || defined(c_plusplus)
132 #endif /* _ASTERISK_LOGGER_H */