qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Christophe Fergeau <cfergeau@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU
Date: Tue, 11 Dec 2018 14:42:11 +0000	[thread overview]
Message-ID: <20181211144211.GJ921@redhat.com> (raw)
In-Reply-To: <20181211143745.17342-1-cfergeau@redhat.com>

On Tue, Dec 11, 2018 at 03:37:45PM +0100, Christophe Fergeau wrote:
> Since spice 0.14.1, it's possible to use g_log_set_default_handler() to
> use a custom function to print spice-server's logs, which gives more
> consistent log output.
> 
> With older spice versions, this is not going to work as expected, but
> will not have any ill effect, so this call is not conditional on spice
> version.
> 
> Since this added g_log_set_default_handler() will bridge glib logging
> and QEMU logging, the call might fit better in a more generic place.

Yeah, I think this is the kind of thing that could go early in
the main() method.

It might also be relevant to integrate it into unit tests and
other tools (qemu-img/nbd/io/etc).

> 
> Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
> ---
>  ui/spice-core.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index ebaae24643..443a2b3d32 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -632,6 +632,30 @@ static void vm_change_state_handler(void *opaque, int running,
>      }
>  }
>  
> +static void qemu_log_func(const gchar *log_domain,
> +                          GLogLevelFlags log_level,
> +                          const gchar *message,
> +                          gpointer user_data)
> +{
> +    switch (log_level & G_LOG_LEVEL_MASK) {
> +        case G_LOG_LEVEL_DEBUG:
> +            break;
> +        case G_LOG_LEVEL_INFO:
> +            /* Fall through */
> +        case G_LOG_LEVEL_MESSAGE:
> +            info_report("%s", message);
> +            break;
> +        case G_LOG_LEVEL_WARNING:
> +            /* Fall through */
> +        case G_LOG_LEVEL_CRITICAL:
> +            warn_report("%s", message);

IIUC, CRITICAL & ERROR are both reporting errors, the
only difference is that  LEVEL_ERROR results in the
process being terminated immediately.

Anyway, I think this means G_LOG_LEVEL_CRITICAL
should use erorr_report too. Only G_LOG_LEVEL_WARNING
should use warn_report

> +            break;
> +        case G_LOG_LEVEL_ERROR:
> +            error_report("%s", message);
> +            break;
> +    }
> +}

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2018-12-11 14:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 14:37 [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU Christophe Fergeau
2018-12-11 14:42 ` Daniel P. Berrangé [this message]
2018-12-11 15:33 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181211144211.GJ921@redhat.com \
    --to=berrange@redhat.com \
    --cc=cfergeau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).