diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/logger.h | 33 | ||||
-rw-r--r-- | include/asterisk/options.h | 9 |
2 files changed, 38 insertions, 4 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) diff --git a/include/asterisk/options.h b/include/asterisk/options.h index d6541fe63..f974ca2c9 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -75,7 +75,11 @@ enum ast_option_flags { /*! Always fork, even if verbose or debug settings are non-zero */ AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), /*! Disable log/verbose output to remote consoles */ - AST_OPT_FLAG_MUTE = (1 << 22) + AST_OPT_FLAG_MUTE = (1 << 22), + /*! There is a per-file debug setting */ + AST_OPT_FLAG_DEBUG_FILE = (1 << 23), + /*! There is a per-file verbose setting */ + AST_OPT_FLAG_VERBOSE_FILE = (1 << 24), }; /*! These are the options that set by default when Asterisk starts */ @@ -103,6 +107,8 @@ enum ast_option_flags { #define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK) #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) +#define ast_opt_dbg_file ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_FILE) +#define ast_opt_verb_file ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE) extern struct ast_flags ast_options; @@ -121,7 +127,6 @@ extern struct timeval ast_lastreloadtime; extern pid_t ast_mainpid; extern char record_cache_dir[AST_CACHE_DIR_LEN]; -extern char debug_filename[AST_FILENAME_MAX]; extern int ast_language_is_prefix; |