[Spice-commits] gtk/spice-util.c
Daniel P. Berrange
berrange at kemper.freedesktop.org
Wed Apr 25 06:00:54 PDT 2012
gtk/spice-util.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
New commits:
commit 3073e240f35115cc78349a58794a6b7a94a6875d
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Wed Apr 25 12:24:09 2012 +0100
Fix --spice-debug flag on glib >= 2.31
With glib >= 2.31 no debug messages are ever printed out by
default, which makes the --spice-debug flag useless. This
fix explicitly turns on the appropriate log domain when
debug is requested. It takes care to preserve the users
own existing log domain requests
diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 1c5d10f..fdea362 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -19,6 +19,8 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include <stdlib.h>
+#include <string.h>
#include <glib-object.h>
#include "spice-util-priv.h"
#include "spice-util.h"
@@ -45,6 +47,18 @@ static gboolean debugFlag = FALSE;
**/
void spice_util_set_debug(gboolean enabled)
{
+#if GLIB_CHECK_VERSION(2, 31, 0)
+ if (enabled) {
+ gchar *doms = getenv("G_MESSAGES_DEBUG");
+ if (!doms) {
+ 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);
+ setenv("G_MESSAGES_DEBUG", newdoms, 1);
+ g_free(newdoms);
+ }
+ }
+#endif
debugFlag = enabled;
}
More information about the Spice-commits
mailing list