Re: [spice-common 1/2] log: Only install glib log handler if SPICE_DEBUG_LEVEL is set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> 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@xxxxxxxxxx>

Frediano

> ---
>  common/log.c | 11 ++++++++---
>  1 file 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
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]