mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 20:44:20 +00:00
This should fix the problem reported in 7564: logger config file errors getting lost because logging isn't configured yet. The problem was that the code that exists to handle this case was not getting reached, because other tests were causing an early return from ast_log().
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@42200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
34
logger.c
34
logger.c
@@ -305,6 +305,7 @@ static void init_logger_chain(void)
|
||||
ast_mutex_unlock(&loglock);
|
||||
|
||||
global_logmask = 0;
|
||||
errno = 0;
|
||||
/* close syslog */
|
||||
closelog();
|
||||
|
||||
@@ -312,7 +313,10 @@ static void init_logger_chain(void)
|
||||
|
||||
/* If no config file, we're fine, set default options. */
|
||||
if (!cfg) {
|
||||
fprintf(stderr, "Unable to open logger.conf: %s\n", strerror(errno));
|
||||
if (errno)
|
||||
fprintf(stderr, "Unable to open logger.conf: %s; default settings will be used.\n", strerror(errno));
|
||||
else
|
||||
fprintf(stderr, "Errors detected in logger.conf: see above; default settings will be used.\n");
|
||||
chan = malloc(sizeof(struct logchannel));
|
||||
memset(chan, 0, sizeof(struct logchannel));
|
||||
chan->type = LOGTYPE_CONSOLE;
|
||||
@@ -696,6 +700,21 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
||||
|
||||
va_list ap;
|
||||
|
||||
if (!logchannels)
|
||||
{
|
||||
/*
|
||||
* we don't have the logger chain configured yet,
|
||||
* so just log to stdout
|
||||
*/
|
||||
if (level != __LOG_VERBOSE) {
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* don't display LOG_DEBUG messages unless option_verbose _or_ option_debug
|
||||
are non-zero; LOG_DEBUG messages can still be displayed if option_debug
|
||||
is zero, if option_verbose is non-zero (this allows for 'level zero'
|
||||
@@ -733,7 +752,6 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
||||
return;
|
||||
}
|
||||
|
||||
if (logchannels) {
|
||||
chan = logchannels;
|
||||
while(chan && !chan->disabled) {
|
||||
/* Check syslog channels */
|
||||
@@ -788,18 +806,6 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
||||
}
|
||||
chan = chan->next;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* we don't have the logger chain configured yet,
|
||||
* so just log to stdout
|
||||
*/
|
||||
if (level != __LOG_VERBOSE) {
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
ast_mutex_unlock(&loglock);
|
||||
/* end critical section */
|
||||
|
Reference in New Issue
Block a user