summaryrefslogtreecommitdiff
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2016-11-23 18:27:54 -0600
committerRichard Mudgett <rmudgett@digium.com>2016-11-30 13:12:56 -0600
commit846c77b28cb4b571b080bc7723c5fea0b2b3016e (patch)
tree86ba0b82215e902c4cf15ddaaf0ca45886bf289a /main/asterisk.c
parent36d380d71c914299f5cb98565c8e3baac9fde9a0 (diff)
PJPROJECT logging: Made easier to get available logging levels.
Use of the new logging is as simple as issuing the new CLI command or setting the new pjproject.conf option. Other options that can affect the logging are how you have the pjproject log levels mapped to Asterisk log types in pjproject.conf and if you have configured Asterisk to log the DEBUG type messages. Altering the pjproject.conf level mapping shouldn't be necessary for most installations as the default mapping is sensible. Configuring Asterisk to log the DEBUG message type is standard practice for collecting debug information. * Added CLI "pjproject set log level" command to dynamically adjust the maximum pjproject log message level. * Added CLI "pjproject show log level" command to see the currently set maximum pjproject log message level. * Added pjproject.conf startup section "log_level" option to set the initial maximum pjproject log message level so all messages could be captured from initialization. * Set PJ_LOG_MAX_LEVEL to 6 to compile in all defined logging levels into bundled pjproject. Pjproject will use the currently set run time log level to determine if a log message is generated just like Asterisk verbose and debug logging levels. * In log_forwarder(), made always log enabled and mapped pjproject log messages. DEBUG mapped log messages are no longer gated by the current Asterisk debug logging level. * Removed RAII_VAR() from res_pjproject.c:get_log_level(). ASTERISK-26630 #close Change-Id: I6dca12979f482ffb0450aaf58db0fe0f6d2e5389
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c33
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");