[Spice-devel] [spice-gtk 1/2] channel: Introduce CHANNEL_DEBUG for channel debug logs

Christophe Fergeau cfergeau at redhat.com
Thu Sep 13 09:01:18 PDT 2012


It automatically prepends the channel name to the log message
for easier debugging.

Fixes rhbz#822437
---
 gtk/channel-base.c       |  17 ++++---
 gtk/channel-cursor.c     |   4 +-
 gtk/channel-display.c    |  32 ++++++-------
 gtk/channel-inputs.c     |   6 +--
 gtk/channel-main.c       |  14 +++---
 gtk/channel-playback.c   |  14 +++---
 gtk/channel-record.c     |   4 +-
 gtk/channel-smartcard.c  |   8 ++--
 gtk/channel-usbredir.c   |  10 ++--
 gtk/spice-channel-priv.h |   3 ++
 gtk/spice-channel.c      | 116 +++++++++++++++++++++++------------------------
 gtk/spice-session.c      |  18 ++++----
 12 files changed, 124 insertions(+), 122 deletions(-)

diff --git a/gtk/channel-base.c b/gtk/channel-base.c
index fa39761..a7e9580 100644
--- a/gtk/channel-base.c
+++ b/gtk/channel-base.c
@@ -53,7 +53,6 @@ void spice_channel_handle_ping(SpiceChannel *channel, SpiceMsgIn *in)
 G_GNUC_INTERNAL
 void spice_channel_handle_notify(SpiceChannel *channel, SpiceMsgIn *in)
 {
-    SpiceChannelPrivate *c = channel->priv;
     static const char* severity_strings[] = {"info", "warn", "error"};
     static const char* visibility_strings[] = {"!", "!!", "!!!"};
 
@@ -74,8 +73,8 @@ void spice_channel_handle_notify(SpiceChannel *channel, SpiceMsgIn *in)
         message_str = (char*)notify->message;
     }
 
-    SPICE_DEBUG("%s: channel %s -- %s%s #%u%s%.*s", __FUNCTION__,
-            c->name, severity, visibility, notify->what,
+    CHANNEL_DEBUG(channel, "%s -- %s%s #%u%s%.*s", __FUNCTION__,
+            severity, visibility, notify->what,
             message_str ? ": " : "", notify->message_len,
             message_str ? message_str : "");
 }
@@ -86,8 +85,8 @@ void spice_channel_handle_disconnect(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpiceMsgDisconnect *disconnect = spice_msg_in_parsed(in);
 
-    SPICE_DEBUG("%s: ts: %" PRIu64", reason: %u", __FUNCTION__,
-                disconnect->time_stamp, disconnect->reason);
+    CHANNEL_DEBUG(channel, "%s: ts: %" PRIu64", reason: %u", __FUNCTION__,
+                  disconnect->time_stamp, disconnect->reason);
 }
 
 typedef struct WaitForChannelData
@@ -126,11 +125,11 @@ void spice_channel_handle_wait_for_channels(SpiceChannel *channel, SpiceMsgIn *i
             .channel = channel
         };
 
-        SPICE_DEBUG("waiting for serial %" PRIu64 " (%d/%d)", data.wait->message_serial, i + 1, wfc->wait_count);
+        CHANNEL_DEBUG(channel, "waiting for serial %" PRIu64 " (%d/%d)", data.wait->message_serial, i + 1, wfc->wait_count);
         if (g_coroutine_condition_wait(&c->coroutine, wait_for_channel, &data))
-            SPICE_DEBUG("waiting for serial %"  PRIu64 ", done", data.wait->message_serial);
+            CHANNEL_DEBUG(channel, "waiting for serial %"  PRIu64 ", done", data.wait->message_serial);
         else
-            SPICE_DEBUG("waiting for serial %" PRIu64 ", cancelled", data.wait->message_serial);
+            CHANNEL_DEBUG(channel, "waiting for serial %" PRIu64 ", cancelled", data.wait->message_serial);
     }
 }
 
@@ -155,7 +154,7 @@ void spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgMigrate *mig = spice_msg_in_parsed(in);
     SpiceChannelPrivate *c = channel->priv;
 
-    SPICE_DEBUG("%s: channel %s flags %u", __FUNCTION__, c->name, mig->flags);
+    CHANNEL_DEBUG(channel, "%s: flags %u", __FUNCTION__, mig->flags);
     if (mig->flags & SPICE_MIGRATE_NEED_FLUSH) {
         /* if peer version > 1: pushing the mark msg before all other messgages and sending it,
          * and only it */
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index 6766b40..45e78c6 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -337,7 +337,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
     guint8 *rgba;
     guint8 val;
 
-    SPICE_DEBUG("%s: type %d, %" PRIx64 ", %dx%d, flags %d, size %d",
+    CHANNEL_DEBUG(channel, "%s: type %d, %" PRIx64 ", %dx%d, flags %d, size %d",
             __FUNCTION__, hdr->type, hdr->unique, hdr->width, hdr->height,
             scursor->flags, scursor->data_size);
 
@@ -485,7 +485,7 @@ static void cursor_handle_reset(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)->priv;
 
-    SPICE_DEBUG("%s, init_done: %d", __FUNCTION__, c->init_done);
+    CHANNEL_DEBUG(channel, "%s, init_done: %d", __FUNCTION__, c->init_done);
 
     delete_cursor_all(channel);
     emit_main_context(channel, SPICE_CURSOR_RESET);
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 326ad22..77959b9 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -410,7 +410,7 @@ gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
     primary->shmid = surface->shmid;
     primary->data = surface->data;
     primary->marked = c->mark;
-    SPICE_DEBUG("get primary %p", primary->data);
+    CHANNEL_DEBUG(channel, "get primary %p", primary->data);
 
     return TRUE;
 }
@@ -714,7 +714,7 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
         if (primary) {
             if (primary->width == surface->width &&
                 primary->height == surface->height) {
-                SPICE_DEBUG("Reusing existing primary surface");
+                CHANNEL_DEBUG(channel, "Reusing existing primary surface");
                 return 0;
             }
 
@@ -724,7 +724,7 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
             free(primary);
         }
 
-        SPICE_DEBUG("display: create primary canvas");
+        CHANNEL_DEBUG(channel, "Create primary canvas");
 #ifdef HAVE_SYS_SHM_H
         surface->shmid = shmget(IPC_PRIVATE, surface->size, IPC_CREAT | 0777);
         if (surface->shmid >= 0) {
@@ -842,7 +842,7 @@ static void clear_surfaces(SpiceChannel *channel, gboolean keep_primary)
         item = ring_next(&c->surfaces, item);
 
         if (keep_primary && surface->primary) {
-            SPICE_DEBUG("keeping exisiting primary surface, migration or reset");
+            CHANNEL_DEBUG(channel, "keeping exisiting primary surface, migration or reset");
             continue;
         }
 
@@ -876,8 +876,8 @@ static void spice_display_channel_up(SpiceChannel *channel)
                  "cache-size", &cache_size,
                  "glz-window-size", &glz_window_size,
                  NULL);
-    SPICE_DEBUG("%s: cache_size %d, glz_window_size %d (bytes)", __FUNCTION__,
-                cache_size, glz_window_size);
+    CHANNEL_DEBUG(channel, "%s: cache_size %d, glz_window_size %d (bytes)", __FUNCTION__,
+                  cache_size, glz_window_size);
     init.pixmap_cache_id = 1;
     init.glz_dictionary_id = 1;
     init.pixmap_cache_size = cache_size / 4; /* pixels */
@@ -925,7 +925,7 @@ static void display_handle_mark(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     display_surface *surface = find_surface(c, 0);
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    CHANNEL_DEBUG(channel, "%s", __FUNCTION__);
     g_return_if_fail(surface != NULL);
 #ifdef EXTRA_CHECKS
     g_warn_if_fail(c->mark == FALSE);
@@ -941,7 +941,7 @@ static void display_handle_reset(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     display_surface *surface = find_surface(c, 0);
 
-    SPICE_DEBUG("%s: TODO detach_from_screen", __FUNCTION__);
+    CHANNEL_DEBUG(channel, "%s: TODO detach_from_screen", __FUNCTION__);
 
     if (surface != NULL)
         surface->canvas->ops->clear(surface->canvas);
@@ -1037,7 +1037,7 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgDisplayStreamCreate *op = spice_msg_in_parsed(in);
     display_stream *st;
 
-    SPICE_DEBUG("%s: id %d", __FUNCTION__, op->id);
+    CHANNEL_DEBUG(channel, "%s: id %d", __FUNCTION__, op->id);
 
     if (op->id >= c->nstreams) {
         int n = c->nstreams;
@@ -1245,7 +1245,7 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
     mmtime = spice_session_get_mm_time(spice_channel_get_session(channel));
 
     if (spice_msg_in_type(in) == SPICE_MSG_DISPLAY_STREAM_DATA_SIZED) {
-        SPICE_DEBUG("stream %d contains sized data", op->id);
+        CHANNEL_DEBUG(channel, "stream %d contains sized data", op->id);
     }
 
     if (op->multi_media_time == 0) {
@@ -1254,8 +1254,8 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
     }
 
     if (op->multi_media_time < mmtime) {
-        SPICE_DEBUG("stream data too late by %u ms (ts: %u, mmtime: %u), dropin",
-                    mmtime - op->multi_media_time, op->multi_media_time, mmtime);
+        CHANNEL_DEBUG(channel, "stream data too late by %u ms (ts: %u, mmtime: %u), dropin",
+                      mmtime - op->multi_media_time, op->multi_media_time, mmtime);
         return;
     }
 
@@ -1334,7 +1334,7 @@ static void display_handle_stream_destroy(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgDisplayStreamDestroy *op = spice_msg_in_parsed(in);
 
     g_return_if_fail(op != NULL);
-    SPICE_DEBUG("%s: id %d", __FUNCTION__, op->id);
+    CHANNEL_DEBUG(channel, "%s: id %d", __FUNCTION__, op->id);
     destroy_stream(channel, op->id);
 }
 
@@ -1492,7 +1492,7 @@ static void display_handle_surface_destroy(SpiceChannel *channel, SpiceMsgIn *in
     }
     if (surface->primary) {
         int id = spice_channel_get_channel_id(channel);
-        SPICE_DEBUG("%d: FIXME primary destroy, but is display really disabled?", id);
+        CHANNEL_DEBUG(channel, "%d: FIXME primary destroy, but is display really disabled?", id);
         /* this is done with a timeout in spicec as well, it's *ugly* */
         if (id != 0 && c->mark_false_event_id == 0) {
             c->mark_false_event_id = g_timeout_add_seconds(1, display_mark_false, channel);
@@ -1517,7 +1517,7 @@ static void display_handle_monitors_config(SpiceChannel *channel, SpiceMsgIn *in
     g_return_if_fail(config != NULL);
     g_return_if_fail(config->count > 0);
 
-    SPICE_DEBUG("monitors config: n: %d/%d", config->count, config->max_allowed);
+    CHANNEL_DEBUG(channel, "monitors config: n: %d/%d", config->count, config->max_allowed);
 
     c->monitors_max = config->max_allowed;
     if (CLAMP_CHECK(c->monitors_max, 1, MONITORS_MAX)) {
@@ -1535,7 +1535,7 @@ static void display_handle_monitors_config(SpiceChannel *channel, SpiceMsgIn *in
     for (i = 0; i < config->count; i++) {
         SpiceDisplayMonitorConfig *mc = &g_array_index(c->monitors, SpiceDisplayMonitorConfig, i);
         SpiceHead *head = &config->heads[i];
-        SPICE_DEBUG("monitor id: %u, surface id: %u, +%u+%u-%ux%u",
+        CHANNEL_DEBUG(channel, "monitor id: %u, surface id: %u, +%u+%u-%ux%u",
                     head->id, head->surface_id,
                     head->x, head->y, head->width, head->height);
         mc->id = head->id;
diff --git a/gtk/channel-inputs.c b/gtk/channel-inputs.c
index 0526738..c907948 100644
--- a/gtk/channel-inputs.c
+++ b/gtk/channel-inputs.c
@@ -197,7 +197,7 @@ static SpiceMsgOut* mouse_position(SpiceInputsChannel *channel)
     if (c->dpy == -1)
         return NULL;
 
-    /* SPICE_DEBUG("%s: +%d+%d", __FUNCTION__, c->x, c->y); */
+    /* CHANNEL_DEBUG(channel, "%s: +%d+%d", __FUNCTION__, c->x, c->y); */
     position.buttons_state = c->bs;
     position.x             = c->x;
     position.y             = c->y;
@@ -366,7 +366,7 @@ void spice_inputs_position(SpiceInputsChannel *channel, gint x, gint y,
     if (c->motion_count < SPICE_INPUT_MOTION_ACK_BUNCH * 2) {
         send_position(channel);
     } else {
-        SPICE_DEBUG("over SPICE_INPUT_MOTION_ACK_BUNCH * 2, dropping");
+        CHANNEL_DEBUG(channel, "over SPICE_INPUT_MOTION_ACK_BUNCH * 2, dropping");
     }
 }
 
@@ -545,7 +545,7 @@ void spice_inputs_key_press_and_release(SpiceInputsChannel *input_channel, guint
         *code = spice_make_scancode(scancode, TRUE);
         spice_msg_out_send(msg);
     } else {
-        SPICE_DEBUG("The server doesn't support atomic press and release");
+        CHANNEL_DEBUG(channel, "The server doesn't support atomic press and release");
         spice_inputs_key_press(input_channel, scancode);
         spice_inputs_key_release(input_channel, scancode);
     }
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index a413ec4..21428cf 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -963,10 +963,10 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
         mon->monitors[j].height = c->display[j].height;
         mon->monitors[j].x = c->display[j].x;
         mon->monitors[j].y = c->display[j].y;
-        SPICE_DEBUG("monitor config: #%d %dx%d+%d+%d @ %d bpp", j,
-                    mon->monitors[j].width, mon->monitors[j].height,
-                    mon->monitors[j].x, mon->monitors[j].y,
-                    mon->monitors[j].depth);
+        CHANNEL_DEBUG(channel, "monitor config: #%d %dx%d+%d+%d @ %d bpp", j,
+                      mon->monitors[j].width, mon->monitors[j].height,
+                      mon->monitors[j].x, mon->monitors[j].y,
+                      mon->monitors[j].depth);
         j++;
     }
 
@@ -1009,7 +1009,7 @@ static void agent_display_config(SpiceMainChannel *channel)
         config.depth = c->display_color_depth;
     }
 
-    SPICE_DEBUG("display_config: flags: %u, depth: %u", config.flags, config.depth);
+    CHANNEL_DEBUG(channel, "display_config: flags: %u, depth: %u", config.flags, config.depth);
 
     agent_msg_queue(channel, VD_AGENT_DISPLAY_CONFIG, sizeof(VDAgentDisplayConfig), &config);
 }
@@ -1064,7 +1064,7 @@ static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection,
     if (HAS_CLIPBOARD_SELECTION(c))
         size += 4;
     else if (selection != VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) {
-        SPICE_DEBUG("Ignoring clipboard grab");
+        CHANNEL_DEBUG(channel, "Ignoring clipboard grab");
         return;
     }
 
@@ -1104,7 +1104,7 @@ static void agent_clipboard_notify(SpiceMainChannel *channel, guint selection,
     if (HAS_CLIPBOARD_SELECTION(c))
         msgsize += 4;
     else if (selection != VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) {
-        SPICE_DEBUG("Ignoring clipboard notify");
+        CHANNEL_DEBUG(channel, "Ignoring clipboard notify");
         return;
     }
 
diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
index 61501c8..2d542a7 100644
--- a/gtk/channel-playback.c
+++ b/gtk/channel-playback.c
@@ -345,8 +345,8 @@ static void playback_handle_data(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgPlaybackPacket *packet = spice_msg_in_parsed(in);
 
 #ifdef DEBUG
-    SPICE_DEBUG("%s: time %d data %p size %d", __FUNCTION__,
-            packet->time, packet->data, packet->data_size);
+    CHANNEL_DEBUG(channel, "%s: time %d data %p size %d", __FUNCTION__,
+                  packet->time, packet->data, packet->data_size);
 #endif
 
     if (c->last_time > packet->time)
@@ -390,8 +390,8 @@ static void playback_handle_mode(SpiceChannel *channel, SpiceMsgIn *in)
     SpicePlaybackChannelPrivate *c = SPICE_PLAYBACK_CHANNEL(channel)->priv;
     SpiceMsgPlaybackMode *mode = spice_msg_in_parsed(in);
 
-    SPICE_DEBUG("%s: time %d mode %d data %p size %d", __FUNCTION__,
-            mode->time, mode->mode, mode->data, mode->data_size);
+    CHANNEL_DEBUG(channel, "%s: time %d mode %d data %p size %d", __FUNCTION__,
+                  mode->time, mode->mode, mode->data, mode->data_size);
 
     c->mode = mode->mode;
     switch (c->mode) {
@@ -411,8 +411,8 @@ static void playback_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgPlaybackStart *start = spice_msg_in_parsed(in);
     int celt_mode_err;
 
-    SPICE_DEBUG("%s: fmt %d channels %d freq %d time %d", __FUNCTION__,
-            start->format, start->channels, start->frequency, start->time);
+    CHANNEL_DEBUG(channel, "%s: fmt %d channels %d freq %d time %d", __FUNCTION__,
+                  start->format, start->channels, start->frequency, start->time);
 
     c->frame_count = 0;
     c->last_time = start->time;
@@ -509,7 +509,7 @@ void spice_playback_channel_set_delay(SpicePlaybackChannel *channel, guint32 del
 
     g_return_if_fail(SPICE_IS_PLAYBACK_CHANNEL(channel));
 
-    SPICE_DEBUG("playback set_delay %u ms", delay_ms);
+    CHANNEL_DEBUG(channel, "playback set_delay %u ms", delay_ms);
 
     c = channel->priv;
     spice_session_set_mm_time(spice_channel_get_session(SPICE_CHANNEL(channel)),
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
index 0ae9e4c..98a36b6 100644
--- a/gtk/channel-record.c
+++ b/gtk/channel-record.c
@@ -443,8 +443,8 @@ static void record_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceRecordChannelPrivate *c = SPICE_RECORD_CHANNEL(channel)->priv;
     SpiceMsgRecordStart *start = spice_msg_in_parsed(in);
 
-    SPICE_DEBUG("%s: fmt %d channels %d freq %d", __FUNCTION__,
-            start->format, start->channels, start->frequency);
+    CHANNEL_DEBUG(channel, "%s: fmt %d channels %d freq %d", __FUNCTION__,
+                  start->format, start->channels, start->frequency);
 
     c->frame_bytes = FRAME_SIZE * 16 * start->channels / 8;
 
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index 5dafd29..cbddc1c 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -327,8 +327,8 @@ static void smartcard_message_send(SpiceSmartcardChannel *channel,
     if (spice_channel_get_read_only(SPICE_CHANNEL(channel)))
         return;
 
-    SPICE_DEBUG("smartcard: send message %d, %s",
-                msg_type, queue ? "queued" : "now");
+    CHANNEL_DEBUG(channel, "send message %d, %s",
+                  msg_type, queue ? "queued" : "now");
     if (!queue) {
         spice_msg_out_send(msg_out);
         return;
@@ -501,11 +501,11 @@ static void handle_smartcard_msg(SpiceChannel *channel, SpiceMsgIn *in)
     VReader *reader;
 
     priv = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(channel);
-    SPICE_DEBUG("smartcard: handle msg %d", msg->type);
+    CHANNEL_DEBUG(channel, "handle msg %d", msg->type);
     switch (msg->type) {
         case VSC_Error:
             g_return_if_fail(priv->in_flight_message != NULL);
-            SPICE_DEBUG("smartcard: in flight %d", priv->in_flight_message->message_type);
+            CHANNEL_DEBUG(channel, "in flight %d", priv->in_flight_message->message_type);
             switch (priv->in_flight_message->message_type) {
                 case VSC_ReaderAdd:
                     g_return_if_fail(priv->pending_reader_additions != NULL);
diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index e7e5629..5f8fb16 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -304,7 +304,7 @@ void spice_usbredir_channel_connect_device_async(
     g_return_if_fail(SPICE_IS_USBREDIR_CHANNEL(channel));
     g_return_if_fail(device != NULL);
 
-    SPICE_DEBUG("connecting usb channel %p", channel);
+    CHANNEL_DEBUG(channel, "connecting usb channel %p", channel);
 
     result = g_simple_async_result_new(G_OBJECT(channel), callback, user_data,
                                  spice_usbredir_channel_connect_device_async);
@@ -373,7 +373,7 @@ void spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel)
 {
     SpiceUsbredirChannelPrivate *priv = channel->priv;
 
-    SPICE_DEBUG("disconnecting device from usb channel %p", channel);
+    CHANNEL_DEBUG(channel, "disconnecting device from usb channel %p", channel);
 
     switch (priv->state) {
     case STATE_DISCONNECTED:
@@ -447,7 +447,7 @@ static void usbredir_log(void *user_data, int level, const char *msg)
     SpiceUsbredirChannelPrivate *priv = channel->priv;
 
     if (priv->catch_error && level == usbredirparser_error) {
-        SPICE_DEBUG("%s", msg);
+        CHANNEL_DEBUG(channel, "%s", msg);
         /* Remove "usbredirhost: " prefix from usbredirhost messages */
         if (strncmp(msg, "usbredirhost: ", 14) == 0)
             g_set_error_literal(priv->catch_error, SPICE_CLIENT_ERROR,
@@ -464,7 +464,7 @@ static void usbredir_log(void *user_data, int level, const char *msg)
         case usbredirparser_warning:
             g_warning("%s", msg); break;
         default:
-            SPICE_DEBUG("%s", msg); break;
+            CHANNEL_DEBUG(channel, "%s", msg); break;
     }
 }
 
@@ -658,7 +658,7 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
         }
         g_free(desc);
 
-        SPICE_DEBUG("%s", err->message);
+        CHANNEL_DEBUG(c, "%s", err->message);
 
         g_boxed_copy(spice_usb_device_get_type(), device);
         emit_main_context(channel, DEVICE_ERROR, device, err);
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index c01b3c4..a769ef8 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -41,6 +41,9 @@ G_BEGIN_DECLS
 
 #define MAX_SPICE_DATA_HEADER_SIZE sizeof(SpiceDataHeader)
 
+#define CHANNEL_DEBUG(channel, fmt, ...) \
+    SPICE_DEBUG("%s: " fmt, SPICE_CHANNEL(channel)->priv->name, ## __VA_ARGS__)
+
 struct _SpiceMsgOut {
     int                   refcount;
     SpiceChannel          *channel;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 7e23bfe..dee0fa3 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -123,7 +123,7 @@ static void spice_channel_constructed(GObject *gobject)
 
     snprintf(c->name, sizeof(c->name), "%s-%d:%d",
              desc ? desc : "unknown", c->channel_type, c->channel_id);
-    SPICE_DEBUG("%s: %s", c->name, __FUNCTION__);
+    CHANNEL_DEBUG(channel, "%s", __FUNCTION__);
 
     c->connection_id = spice_session_get_connection_id(c->session);
     spice_session_channel_new(c->session, channel);
@@ -138,7 +138,7 @@ static void spice_channel_dispose(GObject *gobject)
     SpiceChannel *channel = SPICE_CHANNEL(gobject);
     SpiceChannelPrivate *c = channel->priv;
 
-    SPICE_DEBUG("%s: %s %p", c->name, __FUNCTION__, gobject);
+    CHANNEL_DEBUG(channel, "%s %p", __FUNCTION__, gobject);
 
     if (c->session)
         spice_session_channel_destroy(c->session, channel);
@@ -160,7 +160,7 @@ static void spice_channel_finalize(GObject *gobject)
     SpiceChannel *channel = SPICE_CHANNEL(gobject);
     SpiceChannelPrivate *c = channel->priv;
 
-    SPICE_DEBUG("%s: %s %p", c->name, __FUNCTION__, gobject);
+    CHANNEL_DEBUG(channel, "%s %p", __FUNCTION__, gobject);
 
     g_idle_remove_by_data(gobject);
 
@@ -780,7 +780,7 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
                 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
                     cond = G_IO_OUT;
                 } else {
-                    SPICE_DEBUG("Send error %s", error->message);
+                    CHANNEL_DEBUG(channel, "Send error %s", error->message);
                 }
                 g_clear_error(&error);
                 ret = -1;
@@ -791,13 +791,13 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
                 g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
                 continue;
             } else {
-                SPICE_DEBUG("Closing the channel: spice_channel_flush %d", errno);
+                CHANNEL_DEBUG(channel, "Closing the channel: spice_channel_flush %d", errno);
                 c->has_error = TRUE;
                 return;
             }
         }
         if (ret == 0) {
-            SPICE_DEBUG("Closing the connection: spice_channel_flush");
+            CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_flush");
             c->has_error = TRUE;
             return;
         }
@@ -825,7 +825,7 @@ static void spice_channel_flush_sasl(SpiceChannel *channel, const void *data, si
         return;
     }
 
-    //SPICE_DEBUG("Flush SASL %d: %p %d", len, output, outputlen);
+    //CHANNEL_DEBUG(channel, "Flush SASL %d: %p %d", len, output, outputlen);
     spice_channel_flush_wire(channel, output, outputlen);
 }
 #endif
@@ -907,7 +907,7 @@ reread:
             if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
                 cond = G_IO_IN;
             } else {
-                SPICE_DEBUG("Read error %s", error->message);
+                CHANNEL_DEBUG(channel, "Read error %s", error->message);
             }
             g_clear_error(&error);
             ret = -1;
@@ -924,7 +924,7 @@ reread:
         }
     }
     if (ret == 0) {
-        SPICE_DEBUG("Closing the connection: spice_channel_read() - ret=0");
+        CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_read() - ret=0");
         c->has_error = TRUE;
         return 0;
     }
@@ -941,7 +941,7 @@ static int spice_channel_read_sasl(SpiceChannel *channel, void *data, size_t len
 {
     SpiceChannelPrivate *c = channel->priv;
 
-    /* SPICE_DEBUG("Read %lu SASL %p size %d offset %d", len, c->sasl_decoded, */
+    /* CHANNEL_DEBUG(channel, "Read %lu SASL %p size %d offset %d", len, c->sasl_decoded, */
     /*             c->sasl_decoded_length, c->sasl_decoded_offset); */
 
     if (c->sasl_decoded == NULL || c->sasl_decoded_length == 0) {
@@ -1007,7 +1007,7 @@ static int spice_channel_read(SpiceChannel *channel, void *data, size_t length)
         data = ((char*)data) + ret;
 #if DEBUG
         if (len > 0)
-            SPICE_DEBUG("still needs %" G_GSIZE_FORMAT, len);
+            CHANNEL_DEBUG(channel, "still needs %" G_GSIZE_FORMAT, len);
 #endif
     }
     c->total_read_bytes += length;
@@ -1065,14 +1065,14 @@ static void spice_channel_recv_auth(SpiceChannel *channel)
 
     rc = spice_channel_read(channel, &link_res, sizeof(link_res));
     if (rc != sizeof(link_res)) {
-        SPICE_DEBUG("incomplete auth reply (%d/%" G_GSIZE_FORMAT ")",
+        CHANNEL_DEBUG(channel, "incomplete auth reply (%d/%" G_GSIZE_FORMAT ")",
                     rc, sizeof(link_res));
         emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_LINK);
         return;
     }
 
     if (link_res != SPICE_LINK_ERR_OK) {
-        SPICE_DEBUG("link result: reply %d", link_res);
+        CHANNEL_DEBUG(channel, "link result: reply %d", link_res);
         emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_AUTH);
         return;
     }
@@ -1094,7 +1094,7 @@ void spice_channel_up(SpiceChannel *channel)
 {
     SpiceChannelPrivate *c = channel->priv;
 
-    SPICE_DEBUG("%s: channel up, state %d", c->name, c->state);
+    CHANNEL_DEBUG(channel, "channel up, state %d", c->state);
 
     if (SPICE_CHANNEL_GET_CLASS(channel)->channel_up)
         SPICE_CHANNEL_GET_CLASS(channel)->channel_up(channel);
@@ -1153,11 +1153,11 @@ static void spice_channel_send_link(SpiceChannel *channel)
         *(uint32_t *)p = g_array_index(c->caps, uint32_t, i);
         p += sizeof(uint32_t);
     }
-    SPICE_DEBUG("channel type %d id %d num common caps %d num caps %d",
-                c->link_msg.channel_type,
-                c->link_msg.channel_id,
-                c->link_msg.num_common_caps,
-                c->link_msg.num_channel_caps);
+    CHANNEL_DEBUG(channel, "channel type %d id %d num common caps %d num caps %d",
+                  c->link_msg.channel_type,
+                  c->link_msg.channel_id,
+                  c->link_msg.num_common_caps,
+                  c->link_msg.num_channel_caps);
     spice_channel_write(channel, buffer, p - buffer);
     free(buffer);
 }
@@ -1179,12 +1179,12 @@ static void spice_channel_recv_link_hdr(SpiceChannel *channel)
         goto error;
     }
 
-    SPICE_DEBUG("Peer version: %d:%d", c->peer_hdr.major_version, c->peer_hdr.minor_version);
+    CHANNEL_DEBUG(channel, "Peer version: %d:%d", c->peer_hdr.major_version, c->peer_hdr.minor_version);
     if (c->peer_hdr.major_version != c->link_hdr.major_version) {
         if (c->peer_hdr.major_version == 1) {
             /* enter spice 0.4 mode */
             g_object_set(c->session, "protocol", 1, NULL);
-            SPICE_DEBUG("%s: switching to protocol 1 (spice 0.4)", c->name);
+            CHANNEL_DEBUG(channel, "switching to protocol 1 (spice 0.4)");
             SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
             spice_channel_connect(channel);
             return;
@@ -1260,7 +1260,7 @@ spice_channel_gather_sasl_credentials(SpiceChannel *channel,
         }
     }
 
-    SPICE_DEBUG("Filled SASL interact");
+    CHANNEL_DEBUG(channel, "Filled SASL interact");
 
     return TRUE;
 }
@@ -1334,7 +1334,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
 
     /* Sets up the SASL library as a whole */
     err = sasl_client_init(NULL);
-    SPICE_DEBUG("Client initialize SASL authentication %d", err);
+    CHANNEL_DEBUG(channel, "Client initialize SASL authentication %d", err);
     if (err != SASL_OK) {
         g_critical("failed to initialize SASL library: %d (%s)",
                    err, sasl_errstring(err, NULL, NULL));
@@ -1363,8 +1363,8 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
         (remoteAddr = addr_to_string(addr)) == NULL)
         goto error;
 
-    SPICE_DEBUG("Client SASL new host:'%s' local:'%s' remote:'%s'",
-                spice_session_get_host(c->session), localAddr, remoteAddr);
+    CHANNEL_DEBUG(channel, "Client SASL new host:'%s' local:'%s' remote:'%s'",
+                  spice_session_get_host(c->session), localAddr, remoteAddr);
 
     /* Setup a handle for being a client */
     err = sasl_client_new("spice",
@@ -1431,7 +1431,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
 
 restart:
     /* Start the auth negotiation on the client end first */
-    SPICE_DEBUG("Client start negotiation mechlist '%s'", mechlist);
+    CHANNEL_DEBUG(channel, "Client start negotiation mechlist '%s'", mechlist);
     err = sasl_client_start(saslconn,
                             mechlist,
                             &interact,
@@ -1449,14 +1449,14 @@ restart:
     /* Need to gather some credentials from the client */
     if (err == SASL_INTERACT) {
         if (!spice_channel_gather_sasl_credentials(channel, interact)) {
-            SPICE_DEBUG("Failed to collect auth credentials");
+            CHANNEL_DEBUG(channel, "Failed to collect auth credentials");
             goto error;
         }
         goto restart;
     }
 
-    SPICE_DEBUG("Server start negotiation with mech %s. Data %d bytes %p '%s'",
-                mechname, clientoutlen, clientout, clientout);
+    CHANNEL_DEBUG(channel, "Server start negotiation with mech %s. Data %d bytes %p '%s'",
+                  mechname, clientoutlen, clientout, clientout);
 
     if (clientoutlen > SASL_MAX_DATA_LEN) {
         g_critical("SASL negotiation data too long: %d bytes",
@@ -1482,7 +1482,7 @@ restart:
     if (c->has_error)
         goto error;
 
-    SPICE_DEBUG("Getting sever start negotiation reply");
+    CHANNEL_DEBUG(channel, "Getting sever start negotiation reply");
     /* Read the 'START' message reply from server */
     spice_channel_read(channel, &len, sizeof(len));
     if (c->has_error)
@@ -1506,7 +1506,7 @@ restart:
     if (c->has_error)
         goto error;
 
-    SPICE_DEBUG("Client start result complete: %d. Data %d bytes %p '%s'",
+    CHANNEL_DEBUG(channel, "Client start result complete: %d. Data %d bytes %p '%s'",
                 complete, len, serverin, serverin);
 
     /* Loop-the-loop...
@@ -1530,7 +1530,7 @@ restart:
         if (err == SASL_INTERACT) {
             if (!spice_channel_gather_sasl_credentials(channel,
                                                        interact)) {
-                SPICE_DEBUG("%s", "Failed to collect auth credentials");
+                CHANNEL_DEBUG(channel, "%s", "Failed to collect auth credentials");
                 goto error;
             }
             goto restep;
@@ -1541,7 +1541,7 @@ restart:
             serverin = NULL;
         }
 
-        SPICE_DEBUG("Client step result %d. Data %d bytes %p '%s'", err, clientoutlen, clientout, clientout);
+        CHANNEL_DEBUG(channel, "Client step result %d. Data %d bytes %p '%s'", err, clientoutlen, clientout, clientout);
 
         /* Previous server call showed completion & we're now locally complete too */
         if (complete && err == SASL_OK)
@@ -1562,7 +1562,7 @@ restart:
         if (c->has_error)
             goto error;
 
-        SPICE_DEBUG("Server step with %d bytes %p", clientoutlen, clientout);
+        CHANNEL_DEBUG(channel, "Server step with %d bytes %p", clientoutlen, clientout);
 
         spice_channel_read(channel, &len, sizeof(guint32));
         if (c->has_error)
@@ -1586,7 +1586,7 @@ restart:
         if (c->has_error)
             goto error;
 
-        SPICE_DEBUG("Client step result complete: %d. Data %d bytes %p '%s'",
+        CHANNEL_DEBUG(channel, "Client step result complete: %d. Data %d bytes %p '%s'",
                     complete, len, serverin, serverin);
 
         /* This server call shows complete, and earlier client step was OK */
@@ -1608,7 +1608,7 @@ restart:
             goto error;
         }
         ssf = *(const int *)val;
-        SPICE_DEBUG("SASL SSF value %d", ssf);
+        CHANNEL_DEBUG(channel, "SASL SSF value %d", ssf);
         if (ssf < 56) { /* 56 == DES level, good for Kerberos */
             g_critical("negotiation SSF %d was not strong enough", ssf);
             goto error;
@@ -1616,7 +1616,7 @@ restart:
     }
 
 complete:
-    SPICE_DEBUG("%s", "SASL authentication complete");
+    CHANNEL_DEBUG(channel, "%s", "SASL authentication complete");
     spice_channel_read(channel, &len, sizeof(len));
     if (len != SPICE_LINK_ERR_OK)
         emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_AUTH);
@@ -1663,7 +1663,7 @@ static void spice_channel_recv_link_msg(SpiceChannel *channel)
         break;
     case SPICE_LINK_ERR_NEED_SECURED:
         c->tls = true;
-        SPICE_DEBUG("%s: switching to tls", c->name);
+        CHANNEL_DEBUG(channel, "switching to tls");
         SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
         spice_channel_connect(channel);
         return;
@@ -1674,7 +1674,7 @@ static void spice_channel_recv_link_msg(SpiceChannel *channel)
     }
 
     num_caps = c->peer_msg->num_channel_caps + c->peer_msg->num_common_caps;
-    SPICE_DEBUG("%s: %s: %d caps", c->name, __FUNCTION__, num_caps);
+    CHANNEL_DEBUG(channel, "%s: %d caps", __FUNCTION__, num_caps);
 
     /* see original spice/client code: */
     /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset * sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
@@ -1684,26 +1684,26 @@ static void spice_channel_recv_link_msg(SpiceChannel *channel)
     g_array_set_size(c->remote_common_caps, c->peer_msg->num_common_caps);
     for (i = 0; i < c->peer_msg->num_common_caps; i++, caps++) {
         g_array_index(c->remote_common_caps, uint32_t, i) = *caps;
-        SPICE_DEBUG("got common caps %u:0x%X", i, *caps);
+        CHANNEL_DEBUG(channel, "got common caps %u:0x%X", i, *caps);
     }
 
     g_array_set_size(c->remote_caps, c->peer_msg->num_channel_caps);
     for (i = 0; i < c->peer_msg->num_channel_caps; i++, caps++) {
         g_array_index(c->remote_caps, uint32_t, i) = *caps;
-        SPICE_DEBUG("got channel caps %u:0x%X", i, *caps);
+        CHANNEL_DEBUG(channel, "got channel caps %u:0x%X", i, *caps);
     }
 
     c->state = SPICE_CHANNEL_STATE_AUTH;
     if (!spice_channel_test_common_capability(channel,
             SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION)) {
-        SPICE_DEBUG("Server supports spice ticket auth only");
+        CHANNEL_DEBUG(channel, "Server supports spice ticket auth only");
         spice_channel_send_spice_ticket(channel);
     } else {
         SpiceLinkAuthMechanism auth = { 0, };
 
 #if HAVE_SASL
         if (spice_channel_test_common_capability(channel, SPICE_COMMON_CAP_AUTH_SASL)) {
-            SPICE_DEBUG("Choosing SASL mechanism");
+            CHANNEL_DEBUG(channel, "Choosing SASL mechanism");
             auth.auth_mechanism = SPICE_COMMON_CAP_AUTH_SASL;
             spice_channel_write(channel, &auth, sizeof(auth));
             spice_channel_perform_auth_sasl(channel);
@@ -1720,7 +1720,7 @@ static void spice_channel_recv_link_msg(SpiceChannel *channel)
     }
     c->use_mini_header = spice_channel_test_common_capability(channel,
                                                               SPICE_COMMON_CAP_MINI_HEADER);
-    SPICE_DEBUG("use mini header: %d", c->use_mini_header);
+    CHANNEL_DEBUG(channel, "use mini header: %d", c->use_mini_header);
     return;
 
 error:
@@ -1964,7 +1964,7 @@ void spice_channel_destroy(SpiceChannel *channel)
 {
     g_return_if_fail(channel != NULL);
 
-    SPICE_DEBUG("channel destroy");
+    CHANNEL_DEBUG(channel, "channel destroy");
     spice_channel_disconnect(channel, SPICE_CHANNEL_NONE);
     g_object_unref(channel);
 }
@@ -2018,7 +2018,7 @@ static gboolean wait_migration(gpointer data)
     SpiceChannelPrivate *c = channel->priv;
 
     if (c->state != SPICE_CHANNEL_STATE_MIGRATING) {
-        SPICE_DEBUG("unfreeze channel %s", c->name);
+        CHANNEL_DEBUG(channel, "unfreeze channel");
         return TRUE;
     }
 
@@ -2034,10 +2034,10 @@ static gboolean spice_channel_iterate(SpiceChannel *channel)
     do {
         if (c->state == SPICE_CHANNEL_STATE_MIGRATING &&
             !g_coroutine_condition_wait(&c->coroutine, wait_migration, channel))
-                SPICE_DEBUG("migration wait cancelled");
+                CHANNEL_DEBUG(channel, "migration wait cancelled");
 
         if (c->has_error) {
-            SPICE_DEBUG("channel has error, breaking loop");
+            CHANNEL_DEBUG(channel, "channel has error, breaking loop");
             return FALSE;
         }
 
@@ -2051,7 +2051,7 @@ static gboolean spice_channel_iterate(SpiceChannel *channel)
     } while (ret == 0); /* ret == 0 means no IO condition, but woken up */
 
     if (ret & (G_IO_ERR|G_IO_HUP)) {
-        SPICE_DEBUG("got socket error before read(): %d", ret);
+        CHANNEL_DEBUG(channel, "got socket error before read(): %d", ret);
         emit_main_context(channel, SPICE_CHANNEL_EVENT,
                           c->state == SPICE_CHANNEL_STATE_READY ?
                           SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
@@ -2078,7 +2078,7 @@ static gboolean spice_channel_delayed_unref(gpointer data)
     SpiceChannelPrivate *c = channel->priv;
 
     g_return_val_if_fail(channel != NULL, FALSE);
-    SPICE_DEBUG("Delayed unref channel %s %p", c->name, channel);
+    CHANNEL_DEBUG(channel, "Delayed unref channel %p", channel);
 
     g_return_val_if_fail(c->coroutine.coroutine.exited == TRUE, FALSE);
 
@@ -2095,7 +2095,7 @@ static void *spice_channel_coroutine(void *data)
     guint verify;
     int rc, delay_val = 1;
 
-    SPICE_DEBUG("Started background coroutine %p for %s", &c->coroutine, c->name);
+    CHANNEL_DEBUG(channel, "Started background coroutine %p", &c->coroutine);
 
     if (spice_session_get_client_provided_socket(c->session)) {
         if (c->fd < 0) {
@@ -2105,7 +2105,7 @@ static void *spice_channel_coroutine(void *data)
         }
 
         if (!(c->sock = g_socket_new_from_fd(c->fd, NULL))) {
-                SPICE_DEBUG("Failed to open socket from fd %d", c->fd);
+                CHANNEL_DEBUG(channel, "Failed to open socket from fd %d", c->fd);
                 emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_CONNECT);
                 goto cleanup;
         }
@@ -2119,11 +2119,11 @@ reconnect:
     c->sock = spice_session_channel_open_host(c->session, channel, c->tls);
     if (c->sock == NULL) {
         if (!c->tls) {
-            SPICE_DEBUG("connection failed, trying with TLS port");
+            CHANNEL_DEBUG(channel, "connection failed, trying with TLS port");
             c->tls = true; /* FIXME: does that really work with provided fd */
             goto reconnect;
         } else {
-            SPICE_DEBUG("Connect error");
+            CHANNEL_DEBUG(channel, "Connect error");
             emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_CONNECT);
             goto cleanup;
         }
@@ -2145,7 +2145,7 @@ reconnect:
             const gchar *ca_file = spice_session_get_ca_file (c->session);
 
             g_warn_if_fail(ca_file != NULL);
-            SPICE_DEBUG("CA file: %s", ca_file);
+            CHANNEL_DEBUG(channel, "CA file: %s", ca_file);
             rc = SSL_CTX_load_verify_locations(c->ctx, ca_file, NULL);
 
             if (rc != 1) {
@@ -2234,7 +2234,7 @@ connected:
     }
 
 cleanup:
-    SPICE_DEBUG("Coroutine exit %s", c->name);
+    CHANNEL_DEBUG(channel, "Coroutine exit %s", c->name);
 
     SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
 
@@ -2252,7 +2252,7 @@ static gboolean connect_delayed(gpointer data)
     SpiceChannelPrivate *c = channel->priv;
     struct coroutine *co;
 
-    SPICE_DEBUG("Open coroutine starting %p", channel);
+    CHANNEL_DEBUG(channel, "Open coroutine starting %p", channel);
     c->connect_delayed_id = 0;
 
     co = &c->coroutine.coroutine;
@@ -2447,7 +2447,7 @@ void spice_channel_disconnect(SpiceChannel *channel, SpiceChannelEvent reason)
 {
     SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
 
-    SPICE_DEBUG("channel disconnect %d", reason);
+    CHANNEL_DEBUG(channel, "channel disconnect %d", reason);
     g_return_if_fail(c != NULL);
 
     if (c->state == SPICE_CHANNEL_STATE_UNCONNECTED)
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index b6c7642..5fbc1d2 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1310,19 +1310,19 @@ void spice_session_channel_migrate(SpiceSession *session, SpiceChannel *channel)
 
     id = spice_channel_get_channel_id(channel);
     type = spice_channel_get_channel_type(channel);
-    SPICE_DEBUG("migrating channel id:%d type:%d", id, type);
+    CHANNEL_DEBUG(channel, "migrating channel id:%d type:%d", id, type);
 
     c = spice_session_lookup_channel(s->migration, id, type);
     g_return_if_fail(c != NULL);
 
     if (!g_queue_is_empty(&c->priv->xmit_queue) && s->full_migration) {
-        SPICE_DEBUG("mig channel xmit queue is not empty. type %s", c->priv->name);
+        CHANNEL_DEBUG(channel, "mig channel xmit queue is not empty. type %s", c->priv->name);
     }
     spice_channel_swap(channel, c, !s->full_migration);
     s->migration_left = g_list_remove(s->migration_left, channel);
 
     if (g_list_length(s->migration_left) == 0) {
-        SPICE_DEBUG("all channel migrated");
+        CHANNEL_DEBUG(channel, "all channel migrated");
         spice_session_disconnect(s->migration);
         g_object_unref(s->migration);
         s->migration = NULL;
@@ -1537,22 +1537,22 @@ static GSocket *channel_connect_socket(SpiceChannel *channel,
     if (!g_socket_connect(sock, sockaddr, NULL, error)) {
         if (*error && (*error)->code == G_IO_ERROR_PENDING) {
             g_clear_error(error);
-            SPICE_DEBUG("Socket pending");
+            CHANNEL_DEBUG(channel, "Socket pending");
             g_coroutine_socket_wait(&c->coroutine, sock, G_IO_OUT | G_IO_ERR | G_IO_HUP);
 
             if (!g_socket_check_connect_result(sock, error)) {
-                SPICE_DEBUG("Failed to connect %s", (*error)->message);
+                CHANNEL_DEBUG(channel, "Failed to connect %s", (*error)->message);
                 g_object_unref(sock);
                 return NULL;
             }
         } else {
-            SPICE_DEBUG("Socket error: %s", *error ? (*error)->message : "unknown");
+            CHANNEL_DEBUG(channel, "Socket error: %s", *error ? (*error)->message : "unknown");
             g_object_unref(sock);
             return NULL;
         }
     }
 
-    SPICE_DEBUG("Finally connected");
+    CHANNEL_DEBUG(channel, "Finally connected");
 
     return sock;
 }
@@ -1625,7 +1625,7 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
         if (s->color_depth != 0)
             g_object_set(channel, "color-depth", s->color_depth, NULL);
 
-        SPICE_DEBUG("new main channel, switching");
+        CHANNEL_DEBUG(channel, "new main channel, switching");
         s->cmain = channel;
     }
 
@@ -1655,7 +1655,7 @@ void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel)
     g_return_if_fail(ring != NULL);
 
     if (channel == s->cmain) {
-        SPICE_DEBUG("the session lost the main channel");
+        CHANNEL_DEBUG(channel, "the session lost the main channel");
         s->cmain = NULL;
     }
 
-- 
1.7.11.4



More information about the Spice-devel mailing list