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