changeset 8407:511ceaaa2268 HEAD

Logging: Support specifying a prefix also for syslog logging.
author Timo Sirainen <tss@iki.fi>
date Sat, 15 Nov 2008 19:46:46 +0200
parents ed4d6fc5712b
children cf5a467e991c
files src/lib/failures.c src/lib/failures.h
diffstat 2 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/failures.c	Sat Nov 15 19:37:35 2008 +0200
+++ b/src/lib/failures.c	Sat Nov 15 19:46:46 2008 +0200
@@ -284,16 +284,13 @@
 
 	/* 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;
 }
--- a/src/lib/failures.h	Sat Nov 15 19:37:35 2008 +0200
+++ b/src/lib/failures.h	Sat Nov 15 19:46:46 2008 +0200
@@ -76,7 +76,7 @@
    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. */