[gnome-software] debug: Don't log to journal when started from command line



commit 82d3664ce23d340752fc67b8e0b8126f5f1a48d8
Author: Kalev Lember <klember redhat com>
Date:   Fri Dec 8 15:58:55 2017 +0100

    debug: Don't log to journal when started from command line

 lib/gs-debug.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/lib/gs-debug.c b/lib/gs-debug.c
index 3b61f6c..a683026 100644
--- a/lib/gs-debug.c
+++ b/lib/gs-debug.c
@@ -125,10 +125,10 @@ gs_log_writer_console (GLogLevelFlags log_level,
 }
 
 static GLogWriterOutput
-gs_debug_log_writer (GLogLevelFlags log_level,
-                    const GLogField *fields,
-                    gsize n_fields,
-                    gpointer user_data)
+gs_log_writer_journald (GLogLevelFlags log_level,
+                        const GLogField *fields,
+                        gsize n_fields,
+                        gpointer user_data)
 {
        /* important enough to force to the journal */
        switch (log_level) {
@@ -136,12 +136,25 @@ gs_debug_log_writer (GLogLevelFlags log_level,
        case G_LOG_LEVEL_CRITICAL:
        case G_LOG_LEVEL_WARNING:
        case G_LOG_LEVEL_INFO:
-               g_log_writer_journald (log_level, fields, n_fields, user_data);
+               return g_log_writer_journald (log_level, fields, n_fields, user_data);
                break;
        default:
                break;
        }
-       return gs_log_writer_console (log_level, fields, n_fields, user_data);
+
+       return G_LOG_WRITER_UNHANDLED;
+}
+
+static GLogWriterOutput
+gs_debug_log_writer (GLogLevelFlags log_level,
+                    const GLogField *fields,
+                    gsize n_fields,
+                    gpointer user_data)
+{
+       if (g_log_writer_is_journald (fileno (stderr)))
+               return gs_log_writer_journald (log_level, fields, n_fields, user_data);
+       else
+               return gs_log_writer_console (log_level, fields, n_fields, user_data);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]