[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] spice: Make logging printing go through QEMU
From: |
Christophe Fergeau |
Subject: |
[Qemu-devel] [PATCH] spice: Make logging printing go through QEMU |
Date: |
Tue, 11 Dec 2018 15:37:45 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU,
Christophe Fergeau <=