From 61e3d7a38e7b0efc0d19a0340da2624a1f720b3c Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Thu, 1 Nov 2018 13:44:34 +0100
Subject: [PATCH] udiskslogging: Fix THREAD_ID field logging
The call to g_log_structured() was not conforming the rules stated in the
documentation: "The MESSAGE-format pair has to be the last of the key-value
pairs, and MESSAGE is the only field for which printf()-style formatting
is supported."
---
src/udiskslogging.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/udiskslogging.c b/src/udiskslogging.c
index 47a3af23a..0cb8d959d 100644
--- a/src/udiskslogging.c
+++ b/src/udiskslogging.c
@@ -53,15 +53,19 @@ udisks_log (UDisksLogLevel level,
{
va_list var_args;
gchar *message;
+ gchar *thread_id;
va_start (var_args, format);
message = g_strdup_vprintf (format, var_args);
va_end (var_args);
#if GLIB_CHECK_VERSION(2, 50, 0)
+ thread_id = g_strdup_printf ("%d", (gint) syscall (SYS_gettid));
g_log_structured ("udisks", (GLogLevelFlags) level,
- "MESSAGE", "%s", message, "THREAD_ID", "%d", (gint) syscall (SYS_gettid),
- "CODE_FUNC", function, "CODE_FILE", location);
+ "THREAD_ID", thread_id,
+ "CODE_FUNC", function, "CODE_FILE", location,
+ "MESSAGE", "%s", message);
+ g_free (thread_id);
#else
g_log ("udisks", level, "[%d]: %s [%s, %s()]", (gint) syscall (SYS_gettid), message, location, function);
#endif