Merge "PJPROJECT logging: Made easier to get available logging levels." into 13

This commit is contained in:
Joshua Colp
2016-12-02 05:38:05 -06:00
committed by Gerrit Code Review
8 changed files with 221 additions and 19 deletions

View File

@@ -325,6 +325,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) */
@@ -3891,6 +3892,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 (;;) {
@@ -4612,6 +4644,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");

View File

@@ -37,6 +37,7 @@ ASTERISK_REGISTER_FILE()
#include <pjlib.h>
#endif
#include "asterisk/options.h"
#include "asterisk/_private.h" /* ast_pj_init() */
/*!
@@ -46,6 +47,7 @@ ASTERISK_REGISTER_FILE()
int ast_pj_init(void)
{
#ifdef HAVE_PJPROJECT_BUNDLED
pj_log_set_level(ast_option_pjproject_log_level);
pj_init();
#endif
return 0;