mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-03 13:38:05 +02:00
_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 <smcv@debian.org> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
This commit is contained in:
parent
8ef699dd20
commit
d97d561a46
7 changed files with 31 additions and 22 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4565,7 +4565,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
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue