Skip to content
Snippets Groups Projects
Commit 9b6e2284 authored by Corey Farrell's avatar Corey Farrell
Browse files

Logger: Reset defaults before processing config.

Reset options to default values before reloading config.  This ensures
that if a setting is removed or commented out of the configuration file
it is unset on reload.

ASTERISK-25112 #close
Reported by: Corey Farrell

Change-Id: Id24bb1fb0885c2c14cf8bd6f69a0c2ee7cd6c5bd
parent 4a450f86
No related branches found
No related tags found
No related merge requests found
...@@ -383,16 +383,25 @@ static int init_logger_chain(int locked, const char *altconf) ...@@ -383,16 +383,25 @@ static int init_logger_chain(int locked, const char *altconf)
const char *s; const char *s;
struct ast_flags config_flags = { 0 }; struct ast_flags config_flags = { 0 };
display_callids = 1;
if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
cfg = NULL; cfg = NULL;
} }
/* delete our list of log channels */
if (!locked) { if (!locked) {
AST_RWLIST_WRLOCK(&logchannels); AST_RWLIST_WRLOCK(&logchannels);
} }
/* Set defaults */
hostname[0] = '\0';
display_callids = 1;
memset(&logfiles, 0, sizeof(logfiles));
logfiles.queue_log = 1;
ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
ast_copy_string(queue_log_name, QUEUELOG, sizeof(queue_log_name));
exec_after_rotate[0] = '\0';
rotatestrategy = SEQUENTIAL;
/* delete our list of log channels */
while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list))) { while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list))) {
ast_free(chan); ast_free(chan);
} }
...@@ -432,17 +441,14 @@ static int init_logger_chain(int locked, const char *altconf) ...@@ -432,17 +441,14 @@ static int init_logger_chain(int locked, const char *altconf)
ast_copy_string(hostname, "unknown", sizeof(hostname)); ast_copy_string(hostname, "unknown", sizeof(hostname));
fprintf(stderr, "What box has no hostname???\n"); fprintf(stderr, "What box has no hostname???\n");
} }
} else }
hostname[0] = '\0'; }
} else
hostname[0] = '\0';
if ((s = ast_variable_retrieve(cfg, "general", "display_callids"))) { if ((s = ast_variable_retrieve(cfg, "general", "display_callids"))) {
display_callids = ast_true(s); display_callids = ast_true(s);
} }
if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
ast_copy_string(dateformat, s, sizeof(dateformat)); ast_copy_string(dateformat, s, sizeof(dateformat));
else }
ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) { if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
logfiles.queue_log = ast_true(s); logfiles.queue_log = ast_true(s);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment