diff options
author | Colin Walters <walters@verbum.org> | 2010-03-12 11:30:00 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-03-16 15:57:24 -0400 |
commit | 00e031a543bbc388b667e0c79b947f854b4e7e71 (patch) | |
tree | 25007cb28807c1f27814ea80aa4f0ba72eef9e4b | |
parent | 04cf3166002a86b9a22851be4e243c87b5b3048d (diff) | |
download | dbus-00e031a543bbc388b667e0c79b947f854b4e7e71.tar.gz |
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.
-rw-r--r-- | dbus/dbus-sysdeps-util-unix.c | 8 | ||||
-rw-r--r-- | dbus/dbus-sysdeps.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 42693817..93ad253e 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 4011cab4..12e9124e 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, ...); |