diff options
-rw-r--r-- | include/asterisk/logger.h | 33 | ||||
-rw-r--r-- | include/asterisk/options.h | 9 | ||||
-rw-r--r-- | main/asterisk.c | 2 | ||||
-rw-r--r-- | main/cli.c | 129 | ||||
-rw-r--r-- | main/logger.c | 5 | ||||
-rw-r--r-- | main/pbx.c | 115 |
6 files changed, 208 insertions, 85 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; diff --git a/main/asterisk.c b/main/asterisk.c index 56c588985..7f998123f 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -163,7 +163,6 @@ struct ast_flags ast_options = { AST_DEFAULT_OPTIONS }; int option_verbose; /*!< Verbosity level */ int option_debug; /*!< Debug level */ - 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) */ @@ -174,7 +173,6 @@ long option_minmemfree; /*!< Minimum amount of free system memory - stop acce /*! @} */ char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR; -char debug_filename[AST_FILENAME_MAX] = ""; static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */ static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */ diff --git a/main/cli.c b/main/cli.c index 235afd2f2..71163bc82 100644 --- a/main/cli.c +++ b/main/cli.c @@ -49,6 +49,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "editline/readline/readline.h" #include "asterisk/threadstorage.h" +/*! + * \brief map a debug or verbose value to a filename + */ +struct ast_debug_file { + unsigned int level; + AST_RWLIST_ENTRY(ast_debug_file) entry; + char filename[0]; +}; + +AST_RWLIST_HEAD(debug_file_list, ast_debug_file); + +/*! list of filenames and their debug settings */ +static struct debug_file_list debug_files; +/*! list of filenames and their verbose settings */ +static struct debug_file_list verbose_files; + AST_THREADSTORAGE(ast_cli_buf); /*! \brief Initial buffer size for resulting strings in ast_cli() */ @@ -71,6 +87,40 @@ void ast_cli(int fd, const char *fmt, ...) ast_carefulwrite(fd, buf->str, strlen(buf->str), 100); } +unsigned int ast_debug_get_by_file(const char *file) +{ + struct ast_debug_file *adf; + unsigned int res = 0; + + AST_RWLIST_RDLOCK(&debug_files); + AST_LIST_TRAVERSE(&debug_files, adf, entry) { + if (!strncasecmp(adf->filename, file, strlen(adf->filename))) { + res = adf->level; + break; + } + } + AST_RWLIST_UNLOCK(&debug_files); + + return res; +} + +unsigned int ast_verbose_get_by_file(const char *file) +{ + struct ast_debug_file *adf; + unsigned int res = 0; + + AST_RWLIST_RDLOCK(&verbose_files); + AST_LIST_TRAVERSE(&verbose_files, adf, entry) { + if (!strncasecmp(adf->filename, file, strlen(file))) { + res = adf->level; + break; + } + } + AST_RWLIST_UNLOCK(&verbose_files); + + return res; +} + static AST_LIST_HEAD_STATIC(helpers, ast_cli_entry); static const char logger_mute_help[] = @@ -184,6 +234,23 @@ static char *handle_reload_deprecated(struct ast_cli_entry *e, int cmd, struct a return s; } +/*! + * \brief Find the debug or verbose file setting + * \arg debug 1 for debug, 0 for verbose + */ +static struct ast_debug_file *find_debug_file(const char *fn, unsigned int debug) +{ + struct ast_debug_file *df = NULL; + struct debug_file_list *dfl = debug ? &debug_files : &verbose_files; + + AST_LIST_TRAVERSE(dfl, df, entry) { + if (!strcasecmp(df->filename, fn)) + break; + } + + return df; +} + static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int oldval; @@ -194,14 +261,18 @@ static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_arg char **argv = a->argv; int *dst; char *what; + struct debug_file_list *dfl; + struct ast_debug_file *adf; + char *fn; switch (cmd) { case CLI_INIT: e->command = "core set {debug|verbose} [off|atleast]"; e->usage = - "Usage: core set {debug|verbose} [atleast] <level>\n" + "Usage: core set {debug|verbose} [atleast] <level> [filename]\n" " core set {debug|verbose} off\n" - " Sets level of debug or verbose messages to be displayed.\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; @@ -225,15 +296,67 @@ static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_arg what = "Verbosity"; } if (argc == e->args && !strcasecmp(argv[e->args - 1], "off")) { + unsigned int debug = (*what == 'C'); newlevel = 0; + + dfl = debug ? &debug_files : &verbose_files; + + AST_RWLIST_WRLOCK(dfl); + while ((adf = AST_RWLIST_REMOVE_HEAD(dfl, entry))) + ast_free(adf); + ast_clear_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE); + AST_RWLIST_UNLOCK(dfl); + goto done; } if (!strcasecmp(argv[e->args-1], "atleast")) atleast = 1; - if (argc != e->args + atleast) + if (argc != e->args + atleast && argc != e->args + atleast + 1) return CLI_SHOWUSAGE; if (sscanf(argv[e->args + atleast - 1], "%d", &newlevel) != 1) return CLI_SHOWUSAGE; + if (argc == e->args + atleast + 1) { + unsigned int debug = (*what == 'C'); + dfl = debug ? &debug_files : &verbose_files; + + fn = argv[e->args + atleast]; + + AST_RWLIST_WRLOCK(dfl); + + if ((adf = find_debug_file(fn, debug)) && !newlevel) { + AST_RWLIST_REMOVE(dfl, adf, entry); + if (AST_RWLIST_EMPTY(dfl)) + ast_clear_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE); + AST_RWLIST_UNLOCK(dfl); + ast_cli(fd, "%s was %d and has been set to 0 for '%s'\n", what, adf->level, fn); + ast_free(adf); + return CLI_SUCCESS; + } + + if (adf) { + if ((atleast && newlevel < adf->level) || adf->level == newlevel) { + ast_cli(fd, "%s is %d for '%s'\n", what, adf->level, fn); + AST_RWLIST_UNLOCK(dfl); + return CLI_SUCCESS; + } + } else if (!(adf = ast_calloc(1, sizeof(*adf) + strlen(fn) + 1))) { + AST_RWLIST_UNLOCK(dfl); + return CLI_FAILURE; + } + + oldval = adf->level; + adf->level = newlevel; + strcpy(adf->filename, fn); + + ast_set_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE); + + AST_RWLIST_INSERT_TAIL(dfl, adf, entry); + AST_RWLIST_UNLOCK(dfl); + + ast_cli(fd, "%s was %d and has been set to %d for '%s'\n", what, oldval, adf->level, adf->filename); + + return CLI_SUCCESS; + } done: if (!atleast || newlevel > *dst) diff --git a/main/logger.c b/main/logger.c index ff13115b3..49d4a647f 100644 --- a/main/logger.c +++ b/main/logger.c @@ -81,7 +81,6 @@ static int syslog_level_map[] = { #define GETTID() getpid() #endif - static char dateformat[256] = "%b %e %T"; /* Original Asterisk Format */ static char queue_log_name[256] = QUEUELOG; @@ -909,10 +908,6 @@ void ast_log(int level, const char *file, int line, const char *function, const if (!(global_logmask & (1 << level))) return; - /* Ignore anything other than the currently debugged file if there is one */ - if ((level == __LOG_DEBUG) && !ast_strlen_zero(debug_filename) && strcasecmp(debug_filename, file)) - return; - /* Build string */ va_start(ap, fmt); res = ast_str_set_va(&buf, BUFSIZ, fmt, ap); diff --git a/main/pbx.c b/main/pbx.c index 918fb5f58..bb9692ab1 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1399,8 +1399,7 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) AST_RWLIST_TRAVERSE_SAFE_BEGIN(&acf_root, cur, acflist) { if (cur == acf) { AST_RWLIST_REMOVE_CURRENT(&acf_root, acflist); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name); + ast_verb(2, "Unregistered custom function %s\n", acf->name); break; } } @@ -1442,8 +1441,7 @@ int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_m AST_RWLIST_UNLOCK(&acf_root); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Registered custom function %s\n", acf->name); + ast_verb(2, "Registered custom function %s\n", acf->name); return 0; } @@ -1785,7 +1783,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, } if (option_verbose > 2) { char tmp[80], tmp2[80], tmp3[EXT_DATA_SIZE]; - ast_verbose( VERBOSE_PREFIX_3 "Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n", + ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n", exten, context, priority, term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)), term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), @@ -2368,8 +2366,7 @@ static int __ast_pbx_run(struct ast_channel *c) /* Start by trying whatever the channel is set to */ if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { /* If not successful fall back to 's' */ - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority); + ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority); /* XXX the original code used the existing priority in the call to * ast_exists_extension(), and reset it to 1 afterwards. * I believe the correct thing is to set it to 1 immediately. @@ -2377,8 +2374,7 @@ static int __ast_pbx_run(struct ast_channel *c) set_ext_pri(c, "s", 1); if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { /* JK02: And finally back to default if everything else failed */ - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority); + ast_verb(2, "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority); ast_copy_string(c->context, "default", sizeof(c->context)); } } @@ -2403,14 +2399,12 @@ static int __ast_pbx_run(struct ast_channel *c) } if (res == AST_PBX_KEEPALIVE) { ast_debug(1, "Spawn extension (%s,%s,%d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name); + ast_verb(2, "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name); error = 1; break; } ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); + ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); if (c->_softhangup == AST_SOFTHANGUP_ASYNCGOTO) { c->_softhangup =0; } else if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT) { @@ -2445,8 +2439,7 @@ static int __ast_pbx_run(struct ast_channel *c) * Try to continue at "i", 1 or exit if the latter does not exist. */ if (ast_exists_extension(c, c->context, "i", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name); + ast_verb(3, "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name); pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten); set_ext_pri(c, "i", 1); } else { @@ -2468,8 +2461,7 @@ static int __ast_pbx_run(struct ast_channel *c) const char *status = pbx_builtin_getvar_helper(c, "DIALSTATUS"); if (!status) status = "UNKNOWN"; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "Auto fallthrough, channel '%s' status is '%s'\n", c->name, status); + ast_verb(3, "Auto fallthrough, channel '%s' status is '%s'\n", c->name, status); if (!strcasecmp(status, "CONGESTION")) res = pbx_builtin_congestion(c, "10"); else if (!strcasecmp(status, "CHANUNAVAIL")) @@ -2489,8 +2481,7 @@ static int __ast_pbx_run(struct ast_channel *c) if (!ast_strlen_zero(dst_exten)) { /* An invalid extension */ if (ast_exists_extension(c, c->context, "i", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, c->name); + ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, c->name); pbx_builtin_setvar_helper(c, "INVALID_EXTEN", dst_exten); set_ext_pri(c, "i", 1); } else { @@ -2501,8 +2492,7 @@ static int __ast_pbx_run(struct ast_channel *c) } else { /* A simple timeout */ if (ast_exists_extension(c, c->context, "t", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Timeout on %s\n", c->name); + ast_verb(3, "Timeout on %s\n", c->name); set_ext_pri(c, "t", 1); } else { ast_log(LOG_WARNING, "Timeout, but no rule 't' in context '%s'\n", c->context); @@ -2512,8 +2502,7 @@ static int __ast_pbx_run(struct ast_channel *c) } } if (c->cdr) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "CDR updated on %s\n",c->name); + ast_verb(2, "CDR updated on %s\n",c->name); ast_cdr_update(c); } } @@ -2530,8 +2519,7 @@ static int __ast_pbx_run(struct ast_channel *c) if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) { /* Something bad happened, or a hangup has been requested. */ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); + ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); break; } c->priority++; @@ -2994,8 +2982,7 @@ int ast_register_application2(const char *app, int (*execute)(struct ast_channel if (!cur) AST_RWLIST_INSERT_TAIL(&apps, tmp, list); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); + ast_verb(2, "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); AST_RWLIST_UNLOCK(&apps); @@ -3875,8 +3862,7 @@ int ast_unregister_application(const char *app) if (!strcasecmp(app, tmp->name)) { unreference_cached_app(tmp); AST_RWLIST_REMOVE_CURRENT(&apps, list); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name); + ast_verb(2, "Unregistered application '%s'\n", tmp->name); ast_free(tmp); break; } @@ -3920,8 +3906,7 @@ static struct ast_context *__ast_context_create(struct ast_context **extcontexts tmp->ignorepats = NULL; *local_contexts = tmp; ast_debug(1, "Registered context '%s'\n", tmp->name); - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name); + ast_verb(3, "Registered extension context '%s'\n", tmp->name); } if (!extcontexts) @@ -4369,8 +4354,7 @@ int ast_context_add_include2(struct ast_context *con, const char *value, il->next = new_include; else con->includes = new_include; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); + ast_verb(3, "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); ast_unlock_context(con); @@ -4457,8 +4441,7 @@ int ast_context_add_switch2(struct ast_context *con, const char *value, /* ... sw new context into context list, unlock, return */ AST_LIST_INSERT_TAIL(&con->alts, new_sw, list); - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); + ast_verb(3, "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); ast_unlock_context(con); @@ -4893,15 +4876,15 @@ int ast_add_extension2(struct ast_context *con, tmp->exten, tmp->priority, con->name); } } - if (option_verbose > 2) { - if (tmp->matchcid) { - ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n", - tmp->exten, tmp->priority, tmp->cidmatch, con->name); - } else { - ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n", - tmp->exten, tmp->priority, con->name); - } + + if (tmp->matchcid) { + ast_verb(3, "Added extension '%s' priority %d (CID match '%s')to %s\n", + tmp->exten, tmp->priority, tmp->cidmatch, con->name); + } else { + ast_verb(3, "Added extension '%s' priority %d to %s\n", + tmp->exten, tmp->priority, con->name); } + return 0; } @@ -4947,8 +4930,7 @@ static void *async_wait(void *data) if (!ast_strlen_zero(as->app)) { app = pbx_findapp(as->app); if (app) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Launching %s(%s) on %s\n", as->app, as->appdata, chan->name); + ast_verb(3, "Launching %s(%s) on %s\n", as->app, as->appdata, chan->name); pbx_exec(chan, app, as->appdata); } else ast_log(LOG_WARNING, "No such application '%s'\n", as->app); @@ -5030,8 +5012,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout if (chan) { if (chan->_state == AST_STATE_UP) { res = 0; - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); + ast_verb(4, "Channel %s was answered.\n", chan->name); if (sync > 1) { if (channel) @@ -5055,8 +5036,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout } } } else { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); + ast_verb(4, "Channel %s was never answered.\n", chan->name); if (chan->cdr) { /* update the cdr */ /* here we update the status of the call, which sould be busy. @@ -5153,8 +5133,7 @@ static void *ast_pbx_run_app(void *data) struct ast_app *app; app = pbx_findapp(tmp->app); if (app) { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Launching %s(%s) on %s\n", tmp->app, tmp->data, tmp->chan->name); + ast_verb(4, "Launching %s(%s) on %s\n", tmp->app, tmp->data, tmp->chan->name); pbx_exec(tmp->chan, app, tmp->data); } else ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app); @@ -5202,8 +5181,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, ast_cdr_setaccount(chan, account); if (chan->_state == AST_STATE_UP) { res = 0; - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); + ast_verb(4, "Channel %s was answered.\n", chan->name); tmp = ast_calloc(1, sizeof(*tmp)); if (!tmp) res = -1; @@ -5233,8 +5211,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, } } } else { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); + ast_verb(4, "Channel %s was never answered.\n", chan->name); if (chan->cdr) { /* update the cdr */ /* here we update the status of the call, which sould be busy. * if that fails then we set the status to failed */ @@ -5637,11 +5614,9 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, void *data) res = ast_waitfordigit(chan, ms); if (!res) { if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, continuing...\n", chan->name); + ast_verb(3, "Timeout on %s, continuing...\n", chan->name); } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name); + ast_verb(3, "Timeout on %s, going to 't'\n", chan->name); set_ext_pri(chan, "t", 0); /* XXX is the 0 correct ? */ } else { ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context); @@ -5744,8 +5719,8 @@ done: static int pbx_builtin_goto(struct ast_channel *chan, void *data) { int res = ast_parseable_goto(chan, data); - if (!res && (option_verbose > 2)) - ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1); + if (!res) + ast_verb(3, "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1); return res; } @@ -5826,8 +5801,8 @@ void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, cons headp = (chan) ? &chan->varshead : &globals; if (value) { - if ((option_verbose > 1) && (headp == &globals)) - ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); + if (headp == &globals) + ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value); newvariable = ast_var_assign(name, value); if (headp == &globals) ast_rwlock_wrlock(&globalslock); @@ -5872,8 +5847,8 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const } if (value) { - if ((option_verbose > 1) && (headp == &globals)) - ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); + if (headp == &globals) + ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value); newvariable = ast_var_assign(name, value); AST_LIST_INSERT_HEAD(headp, newvariable, entries); manager_event(EVENT_FLAG_CALL, "VarSet", @@ -6075,16 +6050,14 @@ int load_pbx(void) int x; /* Initialize the PBX */ - if (option_verbose) { - ast_verbose( "Asterisk PBX Core Initializing\n"); - ast_verbose( "Registering builtin applications:\n"); - } + ast_verb(1, "Asterisk PBX Core Initializing\n"); + ast_verb(1, "Registering builtin applications:\n"); + ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry)); /* Register builtin applications */ for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { - if (option_verbose) - ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); + ast_verb(1, "[%s]\n", builtins[x].name); if (ast_register_application2(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description, NULL)) { ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); return -1; |