[Spice-commits] common/log.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 20 16:36:37 UTC 2018
common/log.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
New commits:
commit 82a5f19d998b88b7e1f7c89672f986f88ff7be31
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Jun 20 16:02:47 2018 +0200
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 at redhat.com>
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
More information about the Spice-commits
mailing list