Index: include/asterisk/options.h =================================================================== --- include/asterisk/options.h (revision 75051) +++ include/asterisk/options.h (working copy) @@ -20,6 +20,9 @@ * \brief Options provided by main asterisk program */ +#include "asterisk/logger.h" +#include "asterisk/linkedlists.h" + #ifndef _ASTERISK_OPTIONS_H #define _ASTERISK_OPTIONS_H @@ -109,6 +112,7 @@ extern int option_verbose; extern int option_maxfiles; /*!< Max number of open file handles (files, sockets) */ extern int option_debug; /*!< Debugging */ +extern AST_LIST_HEAD(debug_file_list, ast_debug_file) debug_file_list; extern int option_maxcalls; /*!< Maximum number of simultaneous channels */ extern double option_maxload; #if defined(HAVE_SYSINFO) Index: include/asterisk/logger.h =================================================================== --- include/asterisk/logger.h (revision 75051) +++ include/asterisk/logger.h (working copy) @@ -59,6 +59,14 @@ \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? :-) */ +struct ast_debug_file { + char filename[32]; + /* XXX From AST_LIST_ENTRY , since it cannot be defined in this header file */ + struct { struct ast_debug_file *next; } entry; +}; + +struct ast_debug_file *ast_debug_get_by_file(const char *file); + void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf, 5, 6))); @@ -135,7 +143,7 @@ * to get logged */ #define ast_debug(level, ...) do { \ - if (option_debug >= (level)) { \ + if (option_debug >= (level) || ast_debug_get_by_file(__FILE__)) { \ ast_log(LOG_DEBUG, __VA_ARGS__); \ } \ } while (0) Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 75051) +++ main/asterisk.c (working copy) @@ -163,7 +163,7 @@ int option_verbose; /*!< Verbosity level */ int option_debug; /*!< Debug level */ - +struct debug_file_list debug_file_list = AST_LIST_HEAD_INIT_VALUE; /*!< List of files where ast_debug will always print from */ double option_maxload; /*!< Max load avg on system */ int option_maxcalls; /*!< Max number of active calls */ int option_maxfiles; /*!< Max number of open file handles (files, sockets) */ Index: main/cli.c =================================================================== --- main/cli.c (revision 75051) +++ main/cli.c (working copy) @@ -201,7 +201,9 @@ e->usage = "Usage: core set {debug|verbose} [atleast] \n" " core set {debug|verbose} off\n" - " Sets level of debug or verbose messages to be displayed.\n" + " core set debug \n" + " Sets level of debug or verbose messages to be displayed or \n" + " sets a filename to display debug messages from.\n" " 0 or off means no messages should be displayed.\n" " Equivalent to -d[d[...]] or -v[v[v...]] on startup\n"; return NULL; @@ -232,8 +234,31 @@ atleast = 1; if (argc != e->args + atleast) return CLI_SHOWUSAGE; - if (sscanf(argv[e->args + atleast - 1], "%d", &newlevel) != 1) + if (sscanf(argv[e->args + atleast - 1], "%d", &newlevel) != 1) { + if (*what == 'C') { + struct ast_debug_file *adf; + char *fn = argv[e->args + atleast -1]; + + AST_LIST_LOCK(&debug_file_list); + if ((adf = ast_debug_get_by_file(fn))) { + AST_LIST_REMOVE(&debug_file_list, adf, entry); + ast_cli(fd, "%s has turned debug for '%s' OFF\n", what, fn); + AST_LIST_UNLOCK(&debug_file_list); + return CLI_SUCCESS; + } else { + if (!(adf = ast_calloc(1, sizeof(*adf)))) + return CLI_SUCCESS; + + ast_copy_string(adf->filename, fn, sizeof(adf->filename)); + AST_LIST_INSERT_TAIL(&debug_file_list, adf, entry); + + ast_cli(fd, "%s has turned debug for '%s' ON\n", what, fn); + AST_LIST_UNLOCK(&debug_file_list); + return CLI_SUCCESS; + } + } return CLI_SHOWUSAGE; + } done: if (!atleast || newlevel > *dst) Index: main/logger.c =================================================================== --- main/logger.c (revision 75051) +++ main/logger.c (working copy) @@ -70,6 +70,7 @@ #include "asterisk/manager.h" #include "asterisk/threadstorage.h" #include "asterisk/strings.h" +#include "asterisk/linkedlists.h" #if defined(__linux__) && !defined(__NR_gettid) #include @@ -81,7 +82,17 @@ #define GETTID() getpid() #endif +struct ast_debug_file *ast_debug_get_by_file(const char *file) { + struct ast_debug_file *adf; + AST_LIST_TRAVERSE(&debug_file_list, adf, entry) { + if (!strcasecmp(adf->filename, file)) + return adf; + } + + return NULL; +} + static char dateformat[256] = "%b %e %T"; /* Original Asterisk Format */ static char queue_log_name[256] = QUEUELOG;