From: Colin Walters Date: Fri, 12 Mar 2010 16:30:00 +0000 (-0500) Subject: Add DBUS_SYSTEM_LOG_FATAL severity X-Git-Tag: dbus-1.2.22~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00e031a543bbc388b667e0c79b947f854b4e7e71;p=thirdparty%2Fdbus.git Add DBUS_SYSTEM_LOG_FATAL severity This severity is useful for when we encounter a fatal problem; we get a log message out, then exit. --- diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 426938176..93ad253e2 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -397,6 +397,8 @@ _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) * @param msg a printf-style format string * @param args arguments for the format string * + * If the FATAL severity is given, this function will terminate the program + * with an error code. */ void _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) @@ -410,10 +412,16 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args case DBUS_SYSTEM_LOG_SECURITY: flags = LOG_AUTH | LOG_NOTICE; break; + case DBUS_SYSTEM_LOG_FATAL: + flags = LOG_DAEMON|LOG_CRIT; default: return; } + vsyslog (flags, msg, args); + + if (severity == DBUS_SYSTEM_LOG_FATAL) + exit (1); } /** Installs a UNIX signal handler diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 4011cab4c..12e9124ee 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -442,7 +442,8 @@ void _dbus_init_system_log (void); typedef enum { DBUS_SYSTEM_LOG_INFO, - DBUS_SYSTEM_LOG_SECURITY + DBUS_SYSTEM_LOG_SECURITY, + DBUS_SYSTEM_LOG_FATAL } DBusSystemLogSeverity; void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...);