qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Fergeau <cfergeau@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU
Date: Tue, 11 Dec 2018 15:37:45 +0100	[thread overview]
Message-ID: <20181211143745.17342-1-cfergeau@redhat.com> (raw)

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.

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);
+            break;
+        case G_LOG_LEVEL_ERROR:
+            error_report("%s", message);
+            break;
+    }
+}
+
 void qemu_spice_init(void)
 {
     QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
@@ -647,6 +671,7 @@ void qemu_spice_init(void)
     spice_wan_compression_t wan_compr;
     bool seamless_migration;
 
+    g_log_set_default_handler(qemu_log_func, NULL);
     qemu_thread_get_self(&me);
 
     if (!opts) {
-- 
2.19.2

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 14:37 Christophe Fergeau [this message]
2018-12-11 14:42 ` [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU Daniel P. Berrangé
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=20181211143745.17342-1-cfergeau@redhat.com \
    --to=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).