diff options
author | Joshua Colp <jcolp@digium.com> | 2016-12-02 05:37:38 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-12-02 05:37:38 -0600 |
commit | 197e4083950721861f4377ffb1d4a798a0fcbc0e (patch) | |
tree | b41fefdddc203b56ab1bbee17c3e1e1563168ee0 /main | |
parent | a2343aa20049f1d7174aa599b093a7206155cffb (diff) | |
parent | 1dfa11b65cd3bd768605eb7779214e4330f52ed3 (diff) |
Merge "PJPROJECT logging: Made easier to get available logging levels."
Diffstat (limited to 'main')
-rw-r--r-- | main/asterisk.c | 33 | ||||
-rw-r--r-- | main/libasteriskpj.c | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 98ae8811f..338c1f53b 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -330,6 +330,7 @@ int ast_verb_sys_level; int option_verbose; /*!< Verbosity level */ int option_debug; /*!< Debug level */ +int ast_option_pjproject_log_level; double ast_option_maxload; /*!< Max load avg on system */ int ast_option_maxcalls; /*!< Max number of active calls */ int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */ @@ -3757,6 +3758,37 @@ static void ast_readconfig(void) ast_config_destroy(cfg); } +static void read_pjproject_startup_options(void) +{ + struct ast_config *cfg; + struct ast_variable *v; + struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE | CONFIG_FLAG_NOREALTIME }; + + ast_option_pjproject_log_level = DEFAULT_PJ_LOG_MAX_LEVEL; + + cfg = ast_config_load2("pjproject.conf", "" /* core, can't reload */, config_flags); + if (!cfg + || cfg == CONFIG_STATUS_FILEUNCHANGED + || cfg == CONFIG_STATUS_FILEINVALID) { + /* We'll have to use defaults */ + return; + } + + for (v = ast_variable_browse(cfg, "startup"); v; v = v->next) { + if (!strcasecmp(v->name, "log_level")) { + if (sscanf(v->value, "%30d", &ast_option_pjproject_log_level) != 1) { + ast_option_pjproject_log_level = DEFAULT_PJ_LOG_MAX_LEVEL; + } else if (ast_option_pjproject_log_level < 0) { + ast_option_pjproject_log_level = 0; + } else if (MAX_PJ_LOG_MAX_LEVEL < ast_option_pjproject_log_level) { + ast_option_pjproject_log_level = MAX_PJ_LOG_MAX_LEVEL; + } + } + } + + ast_config_destroy(cfg); +} + static void *monitor_sig_flags(void *unused) { for (;;) { @@ -4513,6 +4545,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou check_init(ast_timing_init(), "Timing"); check_init(ast_ssl_init(), "SSL"); + read_pjproject_startup_options(); check_init(ast_pj_init(), "Embedded PJProject"); check_init(app_init(), "App Core"); check_init(devstate_init(), "Device State Core"); diff --git a/main/libasteriskpj.c b/main/libasteriskpj.c index 22660e686..0f893a2cf 100644 --- a/main/libasteriskpj.c +++ b/main/libasteriskpj.c @@ -35,6 +35,7 @@ #include <pjlib.h> #endif +#include "asterisk/options.h" #include "asterisk/_private.h" /* ast_pj_init() */ /*! @@ -44,6 +45,7 @@ int ast_pj_init(void) { #ifdef HAVE_PJPROJECT_BUNDLED + pj_log_set_level(ast_option_pjproject_log_level); pj_init(); #endif return 0; |