Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7350:51c72fdaadfd HEAD
Prefix fatal/panic messages with syslog.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 05 Mar 2008 02:17:33 +0200 |
parents | 63ef0998cd53 |
children | 6115fe69094c |
files | src/lib/failures.c |
diffstat | 1 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/failures.c Wed Mar 05 02:04:29 2008 +0200 +++ b/src/lib/failures.c Wed Mar 05 02:17:33 2008 +0200 @@ -263,8 +263,8 @@ info_handler = callback; } -static int ATTR_FORMAT(2, 0) -syslog_handler(int level, const char *format, va_list args) +static int ATTR_FORMAT(3, 0) +syslog_handler(int level, enum log_type type, const char *format, va_list args) { static int recursed = 0; @@ -273,11 +273,19 @@ recursed++; - /* make sure there's no %n in there. vsyslog() supports %m, but since - we'll convert it ourself anyway, we might as well it */ - vsyslog(level, printf_format_fix_unsafe(format), args); + /* syslogs don't generatelly bother to log the level in any way, + so make sure fatals and panics are shown clearly */ + if (type == LOG_TYPE_FATAL || type == LOG_TYPE_PANIC) { + T_BEGIN { + syslog(level, "%s%s", failure_log_type_prefixes[type], + t_strdup_vprintf(format, args)); + } T_END; + } else { + /* make sure there's no %n in there. vsyslog() supports %m, but + since we'll convert it ourself anyway, we might as well it */ + vsyslog(level, printf_format_fix_unsafe(format), args); + } recursed--; - return 0; } @@ -285,7 +293,8 @@ const char *fmt, va_list args) { const char *backtrace; - if (syslog_handler(LOG_CRIT, fmt, args) < 0 && status == FATAL_DEFAULT) + if (syslog_handler(LOG_CRIT, type, fmt, args) < 0 && + status == FATAL_DEFAULT) status = FATAL_LOGERROR; if (type == LOG_TYPE_PANIC) { @@ -317,7 +326,7 @@ break; } - if (syslog_handler(level, fmt, args) < 0) + if (syslog_handler(level, type, fmt, args) < 0) failure_exit(FATAL_LOGERROR); }