summaryrefslogtreecommitdiff
path: root/include/asterisk/logger.h
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-07-23 14:21:41 +0000
committerRussell Bryant <russell@russellbryant.com>2007-07-23 14:21:41 +0000
commitf1f72312bbf614f205bef7651f1dea677f58785e (patch)
tree22b55dad3a34eb447cb5783333e6ebad3bec22ce /include/asterisk/logger.h
parentb1791d9349bd43ae1afd70340e1646138cc47b31 (diff)
(closes issue #10192)
Reported by: bbryant Patches: 20070720__core_debug_by_file.patch uploaded by bbryant (license 36) (with some modifications by me) Tested by: russell, bbryant This set of changes introduces the ability to set the core debug or verbose levels on a per-file basis. Interestingly enough, in 1.4, you have the ability to set core debug for a single file, but that functionality was accidentally lost in the conversion of the CLI commands to the new format. This patch improves upon what was in 1.4 by letting you set it for more than 1 file, and by also supporting verbose. *** Janitor Project *** This patch also introduces a new macro, ast_verb(), which is similar to ast_debug(). Setting the per file verbose value only works for messages that use this macro. Converting existing uses of ast_verbose() can be done like: if (option_debug > 2) ast_verbose(VERBOSE_PREFIX_3 "Something useful\n"); ... ast_verb(3, "Something useful\n"); git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76555 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/logger.h')
-rw-r--r--include/asterisk/logger.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 3d2c66b5e..701c1acf9 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -59,6 +59,7 @@ extern "C" {
\param function Will be provided by the LOG_* macro
\param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
*/
+
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
__attribute__ ((format (printf, 5, 6)));
@@ -130,14 +131,42 @@ void ast_console_toggle_mute(int fd);
#define LOG_DTMF __LOG_DTMF, _A_
/*!
+ * \brief Get the debug level for a file
+ * \arg file the filename
+ * \return the debug level
+ */
+unsigned int ast_debug_get_by_file(const char *file);
+
+/*!
+ * \brief Get the debug level for a file
+ * \arg file the filename
+ * \return the debug level
+ */
+unsigned int ast_verbose_get_by_file(const char *file);
+
+/*!
* \brief Log a DEBUG message
* \param level The minimum value of option_debug for this message
* to get logged
*/
#define ast_debug(level, ...) do { \
- if (option_debug >= (level)) { \
+ if (option_debug >= (level) || (ast_opt_dbg_file && ast_debug_get_by_file(__FILE__) >= (level)) ) \
ast_log(LOG_DEBUG, __VA_ARGS__); \
- } \
+} while (0)
+
+#define ast_verb(level, ...) do { \
+ if (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)) ) { \
+ if (level >= 4) \
+ ast_verbose(VERBOSE_PREFIX_4 __VA_ARGS__); \
+ else if (level == 3) \
+ ast_verbose(VERBOSE_PREFIX_3 __VA_ARGS__); \
+ else if (level == 2) \
+ ast_verbose(VERBOSE_PREFIX_2 __VA_ARGS__); \
+ else if (level == 1) \
+ ast_verbose(VERBOSE_PREFIX_1 __VA_ARGS__); \
+ else \
+ ast_verbose(__VA_ARGS__); \
+ } \
} while (0)
#if defined(__cplusplus) || defined(c_plusplus)