From bb3d09ab39d75ca5269723237f4e0eeec916b534 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 15 Nov 2008 19:46:46 +0200 Subject: [PATCH] Logging: Support specifying a prefix also for syslog logging. --HG-- branch : HEAD --- src/lib/failures.c | 17 +++++++---------- src/lib/failures.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/lib/failures.c b/src/lib/failures.c index bcc1da786d..b8999b9122 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -284,16 +284,13 @@ syslog_handler(int level, enum log_type type, const char *format, va_list 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); - } + T_BEGIN { + syslog(level, "%s%s%s", + log_prefix == NULL ? "" : log_prefix, + type == LOG_TYPE_FATAL || type == LOG_TYPE_PANIC ? + failure_log_type_prefixes[type] : "", + t_strdup_vprintf(format, args)); + } T_END; recursed--; return 0; } diff --git a/src/lib/failures.h b/src/lib/failures.h index ec024cbe93..3dec3d6450 100644 --- a/src/lib/failures.h +++ b/src/lib/failures.h @@ -76,7 +76,7 @@ void i_set_failure_internal(void); functions modify the info file too, so call this function after them. */ void i_set_info_file(const char *path); -/* Set the failure prefix. This is used only when logging to a file. */ +/* Set the failure prefix. */ void i_set_failure_prefix(const char *prefix); /* Prefix failures with a timestamp. fmt is in strftime() format. */ -- 2.47.3