qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU
@ 2018-12-11 14:37 Christophe Fergeau
  2018-12-11 14:42 ` Daniel P. Berrangé
  2018-12-11 15:33 ` no-reply
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe Fergeau @ 2018-12-11 14:37 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-11 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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é
2018-12-11 15:33 ` no-reply

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).