From bef489f73c718717350b76f1bdf84e4de1d05d69 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 20 Jul 2016 08:55:14 +0100 Subject: [PATCH] _dbus_system_log: rename to _dbus_log This is a step towards making it write to either stderr or syslog or both, as configured globally. Signed-off-by: Simon McVittie --- bus/bus.c | 7 +++---- bus/config-parser.c | 8 ++++---- dbus/dbus-sysdeps-unix.c | 4 +++- dbus/dbus-sysdeps-win.c | 4 +++- dbus/dbus-sysdeps.c | 6 ++++-- dbus/dbus-sysdeps.h | 8 ++++++-- test/internals/syslog.c | 16 ++++++++-------- 7 files changed, 31 insertions(+), 22 deletions(-) diff --git a/bus/bus.c b/bus/bus.c index b8db6d8..9996be2 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -1378,12 +1378,12 @@ bus_context_log (BusContext *context, DBusSystemLogSeverity severity, const char if (!_dbus_string_append_printf_valist (&full_msg, msg, args)) goto oom_out; - _dbus_system_log (severity, "%s", _dbus_string_get_const_data (&full_msg)); + _dbus_log (severity, "%s", _dbus_string_get_const_data (&full_msg)); oom_out: _dbus_string_free (&full_msg); } else - _dbus_system_logv (severity, msg, args); + _dbus_logv (severity, msg, args); out: va_end (args); @@ -1411,8 +1411,7 @@ bus_context_log_literal (BusContext *context, } else { - _dbus_system_log (severity, "%s%s", nonnull (context->log_prefix, ""), - msg); + _dbus_log (severity, "%s%s", nonnull (context->log_prefix, ""), msg); } } diff --git a/bus/config-parser.c b/bus/config-parser.c index adba69e..8072f59 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -2315,10 +2315,10 @@ include_dir (BusConfigParser *parser, * this bus is going to want to write to syslog! (There's * also some layer inversion going on, if we want to use * the bus context.) */ - _dbus_system_log (DBUS_SYSTEM_LOG_INFO, - "Encountered error '%s' while parsing '%s'\n", - error->message, - _dbus_string_get_const_data (&full_path)); + _dbus_log (DBUS_SYSTEM_LOG_INFO, + "Encountered error '%s' while parsing '%s'\n", + error->message, + _dbus_string_get_const_data (&full_path)); dbus_error_free (error); } } diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 8da129c..79a22c6 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4473,7 +4473,9 @@ _dbus_init_system_log (const char *tag, * with an error code. */ void -_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) +_dbus_logv (DBusSystemLogSeverity severity, + const char *msg, + va_list args) { va_list tmp; #ifdef HAVE_SYSLOG_H diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index efd3d54..32b49b8 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3662,7 +3662,9 @@ _dbus_init_system_log (const char *tag, * with an error code. */ void -_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) +_dbus_logv (DBusSystemLogSeverity severity, + const char *msg, + va_list args) { char *s = ""; char buf[1024]; diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 23ffc86..d004ff0 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -758,13 +758,15 @@ _dbus_strerror_from_errno (void) * @param msg a printf-style format string */ void -_dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) +_dbus_log (DBusSystemLogSeverity severity, + const char *msg, + ...) { va_list args; va_start (args, msg); - _dbus_system_logv (severity, msg, args); + _dbus_logv (severity, msg, args); va_end (args); } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index d5594c7..beb2f1e 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -567,9 +567,13 @@ typedef enum { } DBusSystemLogSeverity; DBUS_PRIVATE_EXPORT -void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) _DBUS_GNUC_PRINTF (2, 3); +void _dbus_log (DBusSystemLogSeverity severity, + const char *msg, + ...) _DBUS_GNUC_PRINTF (2, 3); DBUS_PRIVATE_EXPORT -void _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args); +void _dbus_logv (DBusSystemLogSeverity severity, + const char *msg, + va_list args); /* Define DBUS_VA_COPY() to do the right thing for copying va_list variables. * config.h may have already defined DBUS_VA_COPY as va_copy or __va_copy. diff --git a/test/internals/syslog.c b/test/internals/syslog.c index c0c1f91..c2467be 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -47,7 +47,7 @@ setup (Fixture *f, /* hopefully clear enough that people don't think these messages in syslog * are a bug */ -#define MESSAGE "regression test for _dbus_system_log(): " +#define MESSAGE "regression test for _dbus_log(): " static void test_syslog (Fixture *f, @@ -57,7 +57,7 @@ test_syslog (Fixture *f, if (g_test_trap_fork (0, 0)) { _dbus_init_system_log ("test-syslog", FALSE); - _dbus_system_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23); + _dbus_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23); /* should not be reached: exit 0 so the assertion in the main process * will fail */ exit (0); @@ -69,9 +69,9 @@ test_syslog (Fixture *f, if (g_test_trap_fork (0, 0)) { _dbus_init_system_log ("test-syslog", FALSE); - _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); - _dbus_system_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); - _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); + _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); + _dbus_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); + _dbus_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); exit (0); } @@ -80,9 +80,9 @@ test_syslog (Fixture *f, #endif /* manual test (this is the best we can do on Windows) */ _dbus_init_system_log ("test-syslog", FALSE); - _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); - _dbus_system_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); - _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); + _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); + _dbus_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); + _dbus_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); } static void -- 2.8.1