logger: Console sessions will now respect logger.conf dateformat= option

The 'core' console (ie: asterisk -c) does read logger.conf and does
use the dateformat= option.

Whereas 'remote' consoles (ie: asterisk -r -T) does not read logger.conf
and uses a hard coded dateformat option for printing received verbose messages:
  main/logger.c: static char dateformat[256] = "%b %e %T"

This change will load logger.conf for each remote console session and
use the dateformat= option to set the per-line timestamp for verbose messages

Change-Id: I3ea10990dbd920e9f7ce8ff771bc65aa7f4ea8c1
ASTERISK-25358: #close
Reported-by: Igor Liferenko
This commit is contained in:
Mark Murawski
2021-03-19 10:11:26 -04:00
committed by George Joseph
parent 4393207751
commit a0009c807e
4 changed files with 71 additions and 0 deletions

View File

@@ -679,6 +679,23 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
return chan;
}
void ast_init_logger_for_socket_console(void)
{
struct ast_config *cfg;
const char *s;
struct ast_flags config_flags = { 0 };
if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
return;
}
if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
ast_copy_string(dateformat, s, sizeof(dateformat));
}
ast_config_destroy(cfg);
}
/*!
* \brief Read config, setup channels.
* \param altconf Alternate configuration file to read.