[Spice-devel] [spice-gtk PATCH v1 1/1] channel-usbredir: better control of usbredir log level

Victor Toso victortoso at redhat.com
Tue Dec 1 03:29:37 PST 2015


usbredir on debug level is highly verbose. That does not help much when
we are trying to debug the spice-gtk side of usbredir.

This patch introduces SPICE_DEBUG_USBREDIR env var to set the log level
for usbredir side. If this is not set, usbredir will behave the same way
as it was by checking SPICE_DEBUG env var.

WARNING level is the default when neither env var are set.
---
 src/channel-usbredir.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 0be72ba..84cabe0 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -202,6 +202,16 @@ static void channel_set_handlers(SpiceChannelClass *klass)
 
 /* ------------------------------------------------------------------ */
 /* private api                                                        */
+static gint
+usbredir_get_log_level(void)
+{
+    const gchar *debug_env = g_getenv("SPICE_DEBUG_USBREDIR");
+    if (debug_env != NULL) {
+        return CLAMP(atoi(debug_env), usbredirparser_none, usbredirparser_debug_data);
+    }
+
+    return spice_util_get_debug() ? usbredirparser_debug : usbredirparser_warning;
+}
 
 G_GNUC_INTERNAL
 void spice_usbredir_channel_set_context(SpiceUsbredirChannel *channel,
@@ -223,7 +233,7 @@ void spice_usbredir_channel_set_context(SpiceUsbredirChannel *channel,
                                    usbredir_unlock_lock,
                                    usbredir_free_lock,
                                    channel, PACKAGE_STRING,
-                                   spice_util_get_debug() ? usbredirparser_debug : usbredirparser_warning,
+                                   usbredir_get_log_level(),
                                    usbredirhost_fl_write_cb_owns_buffer);
     if (!priv->host)
         g_error("Out of memory allocating usbredirhost");
-- 
2.5.0



More information about the Spice-devel mailing list