diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2018-06-20 16:02:47 +0200 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2018-06-20 17:35:43 +0100 |
commit | 82a5f19d998b88b7e1f7c89672f986f88ff7be31 (patch) | |
tree | 406f14824fab50f5632e0cdfe1d1b429ad182f3a | |
parent | a3598f62aa9075cb30de4761c4b9cf037b07170e (diff) |
log: Only install glib log handler if SPICE_DEBUG_LEVEL is set
Calling g_log_set_handler() is problematic as this means applications
using spice-server won't be able to use g_log_set_default_handler to
manage spice logging output themselves. Since this call is only needed
for backwards compatibility (so that calling g_log together with
SPICE_DEBUG_LEVEL set has the expected behaviour), we can install it
only when SPICE_DEBUG_LEVEL is set.
Then we should deprecate SPICE_DEBUG_LEVEL once and for all.
Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r-- | common/log.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/common/log.c b/common/log.c index 9b4757b..7e460f0 100644 --- a/common/log.c +++ b/common/log.c @@ -142,9 +142,14 @@ SPICE_CONSTRUCTOR_FUNC(spice_log_init) spice_log_set_debug_level(); spice_log_set_abort_level(); - g_log_set_handler(G_LOG_DOMAIN, - G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - spice_logger, NULL); + if (glib_debug_level != INT_MAX) { + /* If SPICE_DEBUG_LEVEL is set, we need a custom handler, which is + * going to break use of g_log_set_default_handler() by apps + */ + g_log_set_handler(G_LOG_DOMAIN, + G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, + spice_logger, NULL); + } /* Threading is always enabled from 2.31.0 onwards */ /* Our logging is potentially used from different threads. * Older glibs require that g_thread_init() is called when |