diff options
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 6c7a57f9b..fb2ba0968 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -332,6 +332,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) */ @@ -3803,6 +3804,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 (;;) { @@ -4559,6 +4591,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"); |