Made changes corresponding to those in 1.2 here in main/logger.c for bug 7544.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@42208 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Steve Murphy
2006-09-07 03:35:42 +00:00
parent d5f812e0b1
commit 11a7e38930

View File

@@ -295,6 +295,7 @@ static void init_logger_chain(void)
AST_LIST_UNLOCK(&logchannels);
global_logmask = 0;
errno = 0;
/* close syslog */
closelog();
@@ -302,7 +303,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");
if (!(chan = ast_calloc(1, sizeof(*chan))))
return;
chan->type = LOGTYPE_CONSOLE;
@@ -688,6 +692,23 @@ void ast_log(int level, const char *file, int line, const char *function, const
if (!(buf = ast_dynamic_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
return;
if (AST_LIST_EMPTY(&logchannels))
{
/*
* we don't have the logger chain configured yet,
* so just log to stdout
*/
if (level != __LOG_VERBOSE) {
int res;
va_start(ap, fmt);
res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
va_end(ap);
if (res != AST_DYNSTR_BUILD_FAILED)
fputs(buf->str, 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'
@@ -723,7 +744,6 @@ void ast_log(int level, const char *file, int line, const char *function, const
return;
}
if (!AST_LIST_EMPTY(&logchannels)) {
AST_LIST_TRAVERSE(&logchannels, chan, list) {
if (chan->disabled)
break;
@@ -786,20 +806,6 @@ void ast_log(int level, const char *file, int line, const char *function, const
}
}
}
} else {
/*
* we don't have the logger chain configured yet,
* so just log to stdout
*/
if (level != __LOG_VERBOSE) {
int res;
va_start(ap, fmt);
res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
va_end(ap);
if (res != AST_DYNSTR_BUILD_FAILED)
fputs(buf->str, stdout);
}
}
AST_LIST_UNLOCK(&logchannels);