[gnome-software/1756-include-gnome-software-and-dependencies-versions-in-debug-log-output: 24/24] gs-debug: Print gnome-software and OS version information on verbose log start




commit 61ea5b19217cbed104755f8b5fd8ea08fc6a1d34
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 13 08:36:30 2022 +0200

    gs-debug: Print gnome-software and OS version information on verbose log start
    
    That will help to get the information from the log, when the user
    forgets to include it in a report.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1756

 lib/gs-debug.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-debug.c b/lib/gs-debug.c
index db09700c1..1b2da0c2b 100644
--- a/lib/gs-debug.c
+++ b/lib/gs-debug.c
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#include "gs-os-release.h"
 #include "gs-debug.h"
 
 struct _GsDebug
@@ -273,5 +274,22 @@ gs_debug_set_verbose (GsDebug  *self,
 {
        g_return_if_fail (GS_IS_DEBUG (self));
 
-       g_atomic_int_set (&self->verbose, verbose);
+       /* If we’re changing from !verbose → verbose, print OS information.
+        * This is helpful in verbose logs when people file bug reports. */
+       if (g_atomic_int_compare_and_exchange (&self->verbose, !verbose, verbose) &&
+           verbose) {
+               g_autoptr(GsOsRelease) os_release = NULL;
+               g_autoptr(GError) error = NULL;
+
+               g_debug (PACKAGE_NAME " " PACKAGE_VERSION);
+
+               os_release = gs_os_release_new (&error);
+               if (os_release) {
+                       g_debug ("OS: %s; %s",
+                               gs_os_release_get_name (os_release),
+                               gs_os_release_get_version (os_release));
+               } else {
+                       g_debug ("Failed to get OS Release information: %s", error->message);
+               }
+       }
 }


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