[Spice-devel] [spice-gtk v1 1/3] Improve debug log for preferred compression message

Victor Toso victortoso at redhat.com
Wed Dec 20 13:18:01 UTC 2017


From: Victor Toso <me at victortoso.com>

To use a string instead of number (enum)

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/channel-display.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/channel-display.c b/src/channel-display.c
index 75d2e32..dece3b9 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -536,6 +536,29 @@ void spice_display_change_preferred_compression(SpiceChannel *channel, gint comp
     spice_display_channel_change_preferred_compression(channel, compression);
 }
 
+static const gchar *image_compression_types_str[] = {
+    [ SPICE_IMAGE_COMPRESSION_INVALID ] = "invalid",
+    [ SPICE_IMAGE_COMPRESSION_OFF ] = "off",
+    [ SPICE_IMAGE_COMPRESSION_AUTO_GLZ ] = "auto-glz",
+    [ SPICE_IMAGE_COMPRESSION_AUTO_LZ ] = "auto-lz",
+    [ SPICE_IMAGE_COMPRESSION_QUIC ] = "quic",
+    [ SPICE_IMAGE_COMPRESSION_GLZ ] = "glz",
+    [ SPICE_IMAGE_COMPRESSION_LZ ] = "lz",
+    [ SPICE_IMAGE_COMPRESSION_LZ4 ] = "lz4",
+};
+G_STATIC_ASSERT(G_N_ELEMENTS(image_compression_types_str) <= SPICE_IMAGE_COMPRESSION_ENUM_END);
+
+static const gchar *preferred_compression_type_to_string(gint type)
+{
+    const char *str = NULL;
+
+    if (type >= 0 && type < G_N_ELEMENTS(image_compression_types_str)) {
+        str = image_compression_types_str[type];
+    }
+
+    return str ? str : "unknown";
+}
+
 /**
  * spice_display_channel_change_preferred_compression:
  * @channel: a #SpiceDisplayChannel
@@ -560,7 +583,8 @@ void spice_display_channel_change_preferred_compression(SpiceChannel *channel, g
         return;
     }
 
-    CHANNEL_DEBUG(channel, "changing preferred compression to %d", compression);
+    CHANNEL_DEBUG(channel, "changing preferred compression to %s",
+                  preferred_compression_type_to_string(compression));
 
     pref_comp_msg.image_compression = compression;
     out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION);
-- 
2.15.1



More information about the Spice-devel mailing list