[spice-gtk 2/2] Display g_debug messages when SPICE_DEBUG is set

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

 



When SPICE_DEBUG is set but --spice-debug is not used, we fail
to set G_MESSAGES_DEBUG to the log domain used by spice-gtk, which
causes debug messages not to be printed as one would expect.
---
 gtk/spice-util.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 82c5faa..21dfced 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -41,6 +41,20 @@
 
 static GOnce debug_once = G_ONCE_INIT;
 
+static void spice_util_enable_debug_messages(void)
+{
+#if GLIB_CHECK_VERSION(2, 31, 0)
+    const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
+    if (!doms) {
+        g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1);
+    } else if (!strstr(doms, G_LOG_DOMAIN)) {
+        gchar *newdoms = g_strdup_printf("%s %s", doms, G_LOG_DOMAIN);
+        g_setenv("G_MESSAGES_DEBUG", newdoms, 1);
+        g_free(newdoms);
+    }
+#endif
+}
+
 /**
  * spice_util_set_debug:
  * @enabled: %TRUE or %FALSE
@@ -56,24 +70,22 @@ void spice_util_set_debug(gboolean enabled)
      */
     spice_util_get_debug();
 
-#if GLIB_CHECK_VERSION(2, 31, 0)
     if (enabled) {
-        const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
-        if (!doms) {
-            g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1);
-        } else if (!strstr(doms, G_LOG_DOMAIN)) {
-            gchar *newdoms = g_strdup_printf("%s %s", doms, G_LOG_DOMAIN);
-            g_setenv("G_MESSAGES_DEBUG", newdoms, 1);
-            g_free(newdoms);
-        }
+        spice_util_enable_debug_messages();
     }
-#endif
+
     debug_once.retval = GINT_TO_POINTER(enabled);
 }
 
 static gpointer getenv_debug(gpointer data)
 {
-    return GINT_TO_POINTER(g_getenv("SPICE_DEBUG") != NULL);
+    gboolean debug;
+
+    debug = (g_getenv("SPICE_DEBUG") != NULL);
+    if (debug)
+        spice_util_enable_debug_messages();
+
+    return GINT_TO_POINTER(debug);
 }
 
 gboolean spice_util_get_debug(void)
-- 
1.8.3.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]