[Spice-devel] [PATCH spice-gtk] Fix --spice-debug flag on glib >= 2.31
Hans de Goede
hdegoede at redhat.com
Wed Apr 25 04:48:40 PDT 2012
Hi,
Looks good, ack.
Regards,
Hans
On 04/25/2012 01:26 PM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange"<berrange at redhat.com>
>
> 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
> ---
> gtk/spice-util.c | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> 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-devel
mailing list