----- Original Message ----- > Commit 2bd835fb introduced a custom log handler to ensure > we never show debug messages by default regardless of glib > version (older glib were showing them by default). > These messages are only shown if the global variable 'doDebug' > is set (ie when virt-viewer is started with --debug). > > This special log handling is only performed with older glib versions. > However, virt_viewer_app_set_debug() also has some code used with newer > glib version to make sure debug messages are displayed when using > --debug. > > Using the custom log handler regardless of the glib version allows to > get rid of this version-specific code (and avoids a bug with > glib_check_version() with the current code, the check for > glib_check_version() return value is inverted). That changes a bit the behaviour though, you will need to set G_MESSAGES_DEBUG on >2.32 instead of just using --debug. and on > 2.32, you are requiring --debug to print the g_debug() messages (that was not the case before). Imho, a better approach would be to get rid of --debug, and use a G_MESSAGES_DEBUG check on <2.32 to have same behaviour with newer glib and other glib apps and libraries. > --- > The discussions around 'util: fix glib_check_version() condition' made me > realize that we probably don't need the glib version check at all > (only tested with glib 2.40) > > > src/virt-viewer-app.c | 13 ------------- > src/virt-viewer-util.c | 5 ++--- > 2 files changed, 2 insertions(+), 16 deletions(-) > > diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c > index 7dbb7fc..1e81404 100644 > --- a/src/virt-viewer-app.c > +++ b/src/virt-viewer-app.c > @@ -181,19 +181,6 @@ static guint signals[SIGNAL_LAST]; > void > virt_viewer_app_set_debug(gboolean debug) > { > -#if GLIB_CHECK_VERSION(2, 31, 0) > - if (debug) { > - const gchar *doms = g_getenv("G_MESSAGES_DEBUG"); > - if (!doms) { > - g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1); > - } else if (!g_str_equal(doms, "all") && > - !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 > doDebug = debug; > } > > diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c > index c81c09a..cea4fbd 100644 > --- a/src/virt-viewer-util.c > +++ b/src/virt-viewer-util.c > @@ -283,9 +283,8 @@ static void log_handler(const gchar *log_domain, > const gchar *message, > gpointer unused_data) > { > - if (!glib_check_version(2, 32, 0)) > - if (log_level >= G_LOG_LEVEL_DEBUG && !doDebug) > - return; > + if (log_level >= G_LOG_LEVEL_DEBUG && !doDebug) > + return; > > g_log_default_handler(log_domain, log_level, message, unused_data); > } > -- > 1.9.3 > > _______________________________________________ > virt-tools-list mailing list > virt-tools-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/virt-tools-list > _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list