summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-02 17:57:30 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-03 16:19:17 +0000
commit3861a42655ef0d81a8e915738cc6396c2a788d48 (patch)
treec8773399606a72f70bc7a989abb99960ba448b4a /bus
parent5b89e2a839b9d778cc9e4bdc156243f826e26b2b (diff)
downloaddbus-3861a42655ef0d81a8e915738cc6396c2a788d48.tar.gz
bus_context_log_literal: add simplified version of bus_context_log
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810 Reviewed-by: Philip Withnall
Diffstat (limited to 'bus')
-rw-r--r--bus/bus.c22
-rw-r--r--bus/bus.h3
2 files changed, 24 insertions, 1 deletions
diff --git a/bus/bus.c b/bus/bus.c
index 84e6a1fe..d7a068d7 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -1374,6 +1374,26 @@ nonnull (const char *maybe_null,
return (maybe_null ? maybe_null : if_null);
}
+void
+bus_context_log_literal (BusContext *context,
+ DBusSystemLogSeverity severity,
+ const char *msg)
+{
+ if (!context->syslog)
+ {
+ fputs (msg, stderr);
+ fputc ('\n', stderr);
+
+ if (severity == DBUS_SYSTEM_LOG_FATAL)
+ _dbus_exit (1);
+ }
+ else
+ {
+ _dbus_system_log (severity, "%s%s", nonnull (context->log_prefix, ""),
+ msg);
+ }
+}
+
/*
* Log something about a message, usually that it was rejected.
*/
@@ -1432,7 +1452,7 @@ complain_about_message (BusContext *context,
/* If we hit OOM while setting the error, this will syslog "out of memory"
* which is itself an indication that something is seriously wrong */
if (log)
- bus_context_log (context, DBUS_SYSTEM_LOG_SECURITY, "%s",
+ bus_context_log_literal (context, DBUS_SYSTEM_LOG_SECURITY,
stack_error.message);
dbus_move_error (&stack_error, error);
diff --git a/bus/bus.h b/bus/bus.h
index d05c80f0..746e5bad 100644
--- a/bus/bus.h
+++ b/bus/bus.h
@@ -121,6 +121,9 @@ void bus_context_log (BusContext
DBusSystemLogSeverity severity,
const char *msg,
...) _DBUS_GNUC_PRINTF (3, 4);
+void bus_context_log_literal (BusContext *context,
+ DBusSystemLogSeverity severity,
+ const char *msg);
dbus_bool_t bus_context_check_security_policy (BusContext *context,
BusTransaction *transaction,
DBusConnection *sender,