[Spice-devel] [spice-gtk PATCH v2 06/17] log: use spice_debug instead of SPICE_DEBUG

Victor Toso victortoso at redhat.com
Fri Jan 8 00:51:36 PST 2016


Now that spice_debug is using glib log functions, there is no need to
duplicate it with SPICE_DEBUG.

Let's use the spice_debug as it also handles env var to better control
the output.
---
 src/bio-gio.c                |  2 +-
 src/channel-display.c        | 24 ++++++++--------
 src/channel-main.c           | 68 ++++++++++++++++++++++----------------------
 src/channel-playback.c       |  4 +--
 src/decode-glz.c             |  6 ++--
 src/smartcard-manager.c      | 18 ++++++------
 src/spice-channel-priv.h     |  2 +-
 src/spice-channel.c          |  4 +--
 src/spice-common.h           |  1 +
 src/spice-gstaudio.c         | 32 ++++++++++-----------
 src/spice-gtk-session.c      | 18 ++++++------
 src/spice-pulse.c            | 58 ++++++++++++++++++-------------------
 src/spice-session.c          | 30 +++++++++----------
 src/spice-util.c             |  4 +--
 src/spice-util.h             |  1 +
 src/spice-widget.c           | 66 +++++++++++++++++++++---------------------
 src/usb-device-manager.c     | 26 ++++++++---------
 src/usb-device-widget.c      |  2 +-
 src/usbutil.c                |  2 +-
 src/vmcstream.c              | 12 ++++----
 src/vncdisplaykeymap.c       |  2 +-
 src/win-usb-dev.c            |  4 +--
 src/win-usb-driver-install.c | 14 ++++-----
 23 files changed, 201 insertions(+), 199 deletions(-)

diff --git a/src/bio-gio.c b/src/bio-gio.c
index 108ac1a..f6e3fdb 100644
--- a/src/bio-gio.c
+++ b/src/bio-gio.c
@@ -75,7 +75,7 @@ static int bio_gio_destroy(BIO *bio)
     if (bio == NULL || bio->method == NULL)
         return 0;
 
-    SPICE_DEBUG("bio gsocket destroy");
+    spice_debug("bio gsocket destroy");
     g_free(bio->method);
     bio->method = NULL;;
 
diff --git a/src/channel-display.c b/src/channel-display.c
index dc73235..314c248 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -502,7 +502,7 @@ static pixman_image_t *image_get(SpiceImageCache *cache, uint64_t id)
         .image = NULL
     };
     if (!g_coroutine_condition_wait(g_coroutine_self(), wait_image, &wait))
-        SPICE_DEBUG("wait image got cancelled");
+        spice_debug("wait image got cancelled");
 
     return wait.image;
 }
@@ -569,7 +569,7 @@ static pixman_image_t* image_get_lossless(SpiceImageCache *cache, uint64_t id)
         .image = NULL
     };
     if (!g_coroutine_condition_wait(g_coroutine_self(), wait_image, &wait))
-        SPICE_DEBUG("wait lossless got cancelled");
+        spice_debug("wait lossless got cancelled");
 
     return wait.image;
 }
@@ -654,7 +654,7 @@ static void spice_display_channel_init(SpiceDisplayChannel *channel)
     c->monitors_max = 1;
 
     if (g_getenv("SPICE_DISABLE_ADAPTIVE_STREAMING")) {
-        SPICE_DEBUG("adaptive video disabled");
+        spice_debug("adaptive video disabled");
         c->enable_adaptive_streaming = FALSE;
     } else {
         c->enable_adaptive_streaming = TRUE;
@@ -940,7 +940,7 @@ static void display_handle_inv_list(SpiceChannel *channel, SpiceMsgIn *in)
         switch (list->resources[i].type) {
         case SPICE_RES_TYPE_PIXMAP:
             if (!cache_remove(c->images, id))
-                SPICE_DEBUG("fail to remove image %" G_GUINT64_FORMAT, id);
+                spice_debug("fail to remove image %" G_GUINT64_FORMAT, id);
             break;
         default:
             g_return_if_reached();
@@ -1047,7 +1047,7 @@ static gboolean display_stream_schedule(display_stream *st)
     SpiceStreamDataHeader *op;
     SpiceMsgIn *in;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     if (st->timeout || !session)
         return TRUE;
 
@@ -1061,11 +1061,11 @@ static gboolean display_stream_schedule(display_stream *st)
     op = spice_msg_in_parsed(in);
     if (time < op->multi_media_time) {
         d = op->multi_media_time - time;
-        SPICE_DEBUG("scheduling next stream render in %u ms", d);
+        spice_debug("scheduling next stream render in %u ms", d);
         st->timeout = g_timeout_add(d, (GSourceFunc)display_stream_render, st);
         return TRUE;
     } else {
-        SPICE_DEBUG("%s: rendering too late by %u ms (ts: %u, mmtime: %u), dropping ",
+        spice_debug("%s: rendering too late by %u ms (ts: %u, mmtime: %u), dropping ",
                     __FUNCTION__, time - op->multi_media_time,
                     op->multi_media_time, time);
         in = g_queue_pop_head(st->msgq);
@@ -1271,7 +1271,7 @@ static void display_update_stream_report(SpiceDisplayChannel *channel, uint32_t
 
 static void display_stream_reset_rendering_timer(display_stream *st)
 {
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     if (st->timeout != 0) {
         g_source_remove(st->timeout);
         st->timeout = 0;
@@ -1328,7 +1328,7 @@ static void display_session_mm_time_reset_cb(SpiceSession *session, gpointer dat
         if (c->streams[i] == NULL) {
             continue;
         }
-        SPICE_DEBUG("%s: stream-id %d", __FUNCTION__, i);
+        spice_debug("%s: stream-id %d", __FUNCTION__, i);
         st = c->streams[i];
         display_stream_reset_rendering_timer(st);
     }
@@ -1342,7 +1342,7 @@ static void display_stream_test_frames_mm_time_reset(display_stream *st,
     SpiceStreamDataHeader *tail_op, *new_op;
     SpiceMsgIn *tail_msg;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     g_return_if_fail(new_frame_msg != NULL);
     tail_msg = g_queue_peek_tail(st->msgq);
     if (!tail_msg) {
@@ -1352,7 +1352,7 @@ static void display_stream_test_frames_mm_time_reset(display_stream *st,
     new_op = spice_msg_in_parsed(new_frame_msg);
 
     if (new_op->multi_media_time < tail_op->multi_media_time) {
-        SPICE_DEBUG("new-frame-time < tail-frame-time (%u < %u):"
+        spice_debug("new-frame-time < tail-frame-time (%u < %u):"
                     " reseting stream, id %d",
                     new_op->multi_media_time,
                     tail_op->multi_media_time,
@@ -1684,7 +1684,7 @@ static void display_handle_surface_create(SpiceChannel *channel, SpiceMsgIn *in)
     surface->size   = surface->height * surface->stride;
 
     if (create->flags & SPICE_SURFACE_FLAGS_PRIMARY) {
-        SPICE_DEBUG("primary flags: %d", create->flags);
+        spice_debug("primary flags: %d", create->flags);
         surface->primary = true;
         create_canvas(channel, surface);
         if (c->mark_false_event_id != 0) {
diff --git a/src/channel-main.c b/src/channel-main.c
index 06dd121..c48e881 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1112,7 +1112,7 @@ static void monitors_align(VDAgentMonConfig *monitors, int nmonitors)
         monitors[j].y = 0;
         x += monitors[j].width;
         if (monitors[j].width || monitors[j].height)
-            SPICE_DEBUG("#%d +%d+%d-%dx%d", j, monitors[j].x, monitors[j].y,
+            spice_debug("#%d +%d+%d-%dx%d", j, monitors[j].x, monitors[j].y,
                         monitors[j].width, monitors[j].height);
     }
     g_free(sorted_monitors);
@@ -1216,7 +1216,7 @@ static void audio_playback_volume_info_cb(GObject *object, GAsyncResult *res, gp
             spice_warning("Failed to get playback async volume info: %s", error->message);
             g_error_free (error);
         } else {
-            SPICE_DEBUG("Failed to get playback async volume info");
+            spice_debug("Failed to get playback async volume info");
         }
         main_channel->priv->agent_volume_playback_sync = FALSE;
         return;
@@ -1229,7 +1229,7 @@ static void audio_playback_volume_info_cb(GObject *object, GAsyncResult *res, gp
     avs->nchannels = nchannels;
     memcpy(avs->volume, volume, array_size);
 
-    SPICE_DEBUG("%s mute=%s nchannels=%u volume[0]=%u",
+    spice_debug("%s mute=%s nchannels=%u volume[0]=%u",
                 __func__, spice_yes_no(mute), nchannels, volume[0]);
     g_free(volume);
     agent_msg_queue(main_channel, VD_AGENT_AUDIO_VOLUME_SYNC,
@@ -1245,7 +1245,7 @@ static void agent_sync_audio_playback(SpiceMainChannel *main_channel)
     if (audio == NULL ||
         !test_agent_cap(main_channel, VD_AGENT_CAP_AUDIO_VOLUME_SYNC) ||
         c->agent_volume_playback_sync == TRUE) {
-        SPICE_DEBUG("%s - is not going to sync audio with guest", __func__);
+        spice_debug("%s - is not going to sync audio with guest", __func__);
         return;
     }
     /* only one per connection */
@@ -1273,7 +1273,7 @@ static void audio_record_volume_info_cb(GObject *object, GAsyncResult *res, gpoi
             spice_warning ("Failed to get record async volume info: %s", error->message);
             g_error_free (error);
         } else {
-            SPICE_DEBUG("Failed to get record async volume info");
+            spice_debug("Failed to get record async volume info");
         }
         main_channel->priv->agent_volume_record_sync = FALSE;
         return;
@@ -1286,7 +1286,7 @@ static void audio_record_volume_info_cb(GObject *object, GAsyncResult *res, gpoi
     avs->nchannels = nchannels;
     memcpy(avs->volume, volume, array_size);
 
-    SPICE_DEBUG("%s mute=%s nchannels=%u volume[0]=%u",
+    spice_debug("%s mute=%s nchannels=%u volume[0]=%u",
                 __func__, spice_yes_no(mute), nchannels, volume[0]);
     g_free(volume);
     agent_msg_queue(main_channel, VD_AGENT_AUDIO_VOLUME_SYNC,
@@ -1302,7 +1302,7 @@ static void agent_sync_audio_record(SpiceMainChannel *main_channel)
     if (audio == NULL ||
         !test_agent_cap(main_channel, VD_AGENT_CAP_AUDIO_VOLUME_SYNC) ||
         c->agent_volume_record_sync == TRUE) {
-        SPICE_DEBUG("%s - is not going to sync audio with guest", __func__);
+        spice_debug("%s - is not going to sync audio with guest", __func__);
         return;
     }
     /* only one per connection */
@@ -1462,7 +1462,7 @@ static void agent_clipboard_request(SpiceMainChannel *channel, guint selection,
     if (test_agent_cap(channel, VD_AGENT_CAP_CLIPBOARD_SELECTION)) {
         msgsize += 4;
     } else if (selection != VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) {
-        SPICE_DEBUG("Ignoring clipboard request");
+        spice_debug("Ignoring clipboard request");
         return;
     }
 
@@ -1496,7 +1496,7 @@ static void agent_clipboard_release(SpiceMainChannel *channel, guint selection)
         msg[0] = selection;
         msgsize += 4;
     } else if (selection != VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) {
-        SPICE_DEBUG("Ignoring clipboard release");
+        spice_debug("Ignoring clipboard release");
         return;
     }
 
@@ -1532,7 +1532,7 @@ static gboolean timer_set_display(gpointer data)
         return FALSE;
 
     if (!any_display_has_dimensions(channel)) {
-        SPICE_DEBUG("Not sending monitors config, at least one monitor must have dimensions");
+        spice_debug("Not sending monitors config, at least one monitor must have dimensions");
         return FALSE;
     }
 
@@ -1543,7 +1543,7 @@ static gboolean timer_set_display(gpointer data)
            number of display channels */
         for (i = 0; i < spice_session_get_n_display_channels(session); i++)
             if (c->display[i].display_state == DISPLAY_UNDEFINED) {
-                SPICE_DEBUG("Not sending monitors config, missing monitors");
+                spice_debug("Not sending monitors config, missing monitors");
                 return FALSE;
             }
     }
@@ -1568,7 +1568,7 @@ static void set_agent_connected(SpiceMainChannel *channel, gboolean connected)
 {
     SpiceMainChannelPrivate *c = channel->priv;
 
-    SPICE_DEBUG("agent connected: %s", spice_yes_no(connected));
+    spice_debug("agent connected: %s", spice_yes_no(connected));
     if (connected != c->agent_connected) {
         c->agent_connected = connected;
         g_coroutine_object_notify(G_OBJECT(channel), "agent-connected");
@@ -1669,7 +1669,7 @@ static void main_handle_name(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgMainName *name = spice_msg_in_parsed(in);
     SpiceSession *session = spice_channel_get_session(channel);
 
-    SPICE_DEBUG("server name: %s", name->name);
+    spice_debug("server name: %s", name->name);
     spice_session_set_name(session, (const gchar *)name->name);
 }
 
@@ -1680,7 +1680,7 @@ static void main_handle_uuid(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceSession *session = spice_channel_get_session(channel);
     gchar *uuid_str = spice_uuid_to_string(uuid->uuid);
 
-    SPICE_DEBUG("server uuid: %s", uuid_str);
+    spice_debug("server uuid: %s", uuid_str);
     spice_session_set_uuid(session, uuid->uuid);
 
     g_free(uuid_str);
@@ -1787,7 +1787,7 @@ static void file_xfer_close_cb(GObject      *object,
         g_input_stream_close_finish(stream, close_res, &error);
         if (error) {
             /* This error dont need to report to user, just print a log */
-            SPICE_DEBUG("close file error: %s", error->message);
+            spice_debug("close file error: %s", error->message);
             g_clear_error(&error);
         }
     }
@@ -1811,7 +1811,7 @@ static void file_xfer_close_cb(GObject      *object,
             gchar *transfer_speed_str = g_format_size(self->priv->file_size / seconds);
 
             g_warn_if_fail(self->priv->read_bytes == self->priv->file_size);
-            SPICE_DEBUG("transferred file %s of %s size in %.1f seconds (%s/s)",
+            spice_debug("transferred file %s of %s size in %.1f seconds (%s/s)",
                         basename, file_size_str, seconds, transfer_speed_str);
 
             g_free(basename);
@@ -1847,7 +1847,7 @@ static void file_xfer_data_flushed_cb(GObject *source_object,
         if (interval < now - self->priv->last_update) {
             gchar *basename = g_file_get_basename(self->priv->file);
             self->priv->last_update = now;
-            SPICE_DEBUG("transferred %.2f%% of the file %s",
+            spice_debug("transferred %.2f%% of the file %s",
                         100.0 * self->priv->read_bytes / self->priv->file_size, basename);
             g_free(basename);
         }
@@ -1955,11 +1955,11 @@ static void file_xfer_handle_status(SpiceMainChannel *channel,
 
     task = g_hash_table_lookup(c->file_xfer_tasks, GUINT_TO_POINTER(msg->id));
     if (task == NULL) {
-        SPICE_DEBUG("cannot find task %d", msg->id);
+        spice_debug("cannot find task %d", msg->id);
         return;
     }
 
-    SPICE_DEBUG("task %d received response %d", msg->id, msg->result);
+    spice_debug("task %d received response %d", msg->id, msg->result);
 
     switch (msg->result) {
     case VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:
@@ -2059,7 +2059,7 @@ static void main_agent_handle_msg(SpiceChannel *channel,
         for (i = 0; i < size * 32; i++) {
             if (!VD_AGENT_HAS_CAPABILITY(caps->caps, size, i))
                 continue;
-            SPICE_DEBUG("%s: cap: %d (%s)", __FUNCTION__,
+            spice_debug("%s: cap: %d (%s)", __FUNCTION__,
                         i, NAME(agent_caps, i));
             VD_AGENT_SET_CAPABILITY(c->agent_caps, i);
         }
@@ -2129,7 +2129,7 @@ static void main_agent_handle_msg(SpiceChannel *channel,
     case VD_AGENT_REPLY:
     {
         VDAgentReply *reply = payload;
-        SPICE_DEBUG("%s: reply: type %d, %s", __FUNCTION__, reply->type,
+        spice_debug("%s: reply: type %d, %s", __FUNCTION__, reply->type,
                     reply->error == VD_AGENT_SUCCESS ? "success" : "error");
         break;
     }
@@ -2155,7 +2155,7 @@ static void main_handle_agent_data_msg(SpiceChannel* channel, int* msg_size, guc
         *msg_size -= n;
         *msg_pos += n;
         if (c->agent_msg_pos == sizeof(VDAgentMessage)) {
-            SPICE_DEBUG("agent msg start: msg_size=%d, protocol=%d, type=%d",
+            spice_debug("agent msg start: msg_size=%d, protocol=%d, type=%d",
                         c->agent_msg.size, c->agent_msg.protocol, c->agent_msg.type);
             g_return_if_fail(c->agent_msg_data == NULL);
             c->agent_msg_data = g_malloc0(c->agent_msg.size);
@@ -2227,7 +2227,7 @@ static void migrate_channel_new_cb(SpiceSession *s, SpiceChannel *channel, gpoin
 
 static SpiceChannel* migrate_channel_connect(spice_migrate *mig, int type, int id)
 {
-    SPICE_DEBUG("migrate_channel_connect %d:%d", type, id);
+    spice_debug("migrate_channel_connect %d:%d", type, id);
 
     SpiceChannel *newc = spice_channel_new(mig->session, type, id);
     spice_channel_connect(newc);
@@ -2299,12 +2299,12 @@ static void migrate_channel_event_cb(SpiceChannel *channel, SpiceChannelEvent ev
             mig->nchannels--;
         }
 
-        SPICE_DEBUG("migration: channel opened chan:%p, left %d", channel, mig->nchannels);
+        spice_debug("migration: channel opened chan:%p, left %d", channel, mig->nchannels);
         if (mig->nchannels == 0)
             coroutine_yieldto(mig->from, NULL);
         break;
     default:
-        SPICE_DEBUG("error or unhandled channel event during migration: %d", event);
+        spice_debug("error or unhandled channel event during migration: %d", event);
         /* go back to main channel to report error */
         coroutine_yieldto(mig->from, NULL);
     }
@@ -2356,14 +2356,14 @@ static gboolean migrate_connect(gpointer data)
     if ((c->peer_hdr.major_version == 1) &&
         (c->peer_hdr.minor_version < 1)) {
         OldRedMigrationBegin *info = (OldRedMigrationBegin *)mig->info;
-        SPICE_DEBUG("migrate_begin old %s %d %d",
+        spice_debug("migrate_begin old %s %d %d",
                     info->host, info->port, info->sport);
         port = info->port;
         sport = info->sport;
         host = info->host;
     } else {
         SpiceMigrationDstInfo *info = mig->info;
-        SPICE_DEBUG("migrate_begin %d %s %d %d",
+        spice_debug("migrate_begin %d %s %d %d",
                     info->host_size, info->host_data, info->port, info->sport);
         port = info->port;
         sport = info->sport;
@@ -2453,10 +2453,10 @@ static void main_migrate_connect(SpiceChannel *channel,
         spice_session_abort_migration(session);
     } else {
         if (mig.do_seamless) {
-            SPICE_DEBUG("migration (seamless): connections all ok");
+            spice_debug("migration (seamless): connections all ok");
             reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECTED_SEAMLESS;
         } else {
-            SPICE_DEBUG("migration (semi-seamless): connections all ok");
+            spice_debug("migration (semi-seamless): connections all ok");
             reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECTED;
         }
         spice_session_start_migrating(spice_channel_get_session(channel),
@@ -2524,7 +2524,7 @@ static void main_handle_migrate_end(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpiceMainChannelPrivate *c = SPICE_MAIN_CHANNEL(channel)->priv;
 
-    SPICE_DEBUG("migrate end");
+    spice_debug("migrate end");
 
     g_return_if_fail(c->migrate_delayed_id == 0);
     g_return_if_fail(spice_channel_test_capability(channel, SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE));
@@ -2566,7 +2566,7 @@ static void main_handle_migrate_switch_host(SpiceChannel *channel, SpiceMsgIn *i
         g_return_if_fail(subject[mig->cert_subject_size - 1] == '\0');
     }
 
-    SPICE_DEBUG("migrate_switch %s %d %d %s",
+    spice_debug("migrate_switch %s %d %d %s",
                 host, mig->port, mig->sport, subject);
 
     if (c->switch_host_delayed_id != 0) {
@@ -2593,7 +2593,7 @@ static void main_handle_migrate_cancel(SpiceChannel *channel,
 {
     SpiceSession *session;
 
-    SPICE_DEBUG("migrate_cancel");
+    spice_debug("migrate_cancel");
     session = spice_channel_get_session(channel);
     spice_session_abort_migration(session);
 }
@@ -2941,7 +2941,7 @@ static void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
     if (self->priv->error)
         g_clear_error(&error);
     if (error) {
-        SPICE_DEBUG("File %s xfer failed: %s",
+        spice_debug("File %s xfer failed: %s",
                     g_file_get_path(self->priv->file), error->message);
         self->priv->error = error;
     }
@@ -3279,7 +3279,7 @@ spice_file_transfer_task_constructed(GObject *object)
         self->priv->start_time = g_get_monotonic_time();
         self->priv->last_update = self->priv->start_time;
 
-        SPICE_DEBUG("transfer of file %s has started", basename);
+        spice_debug("transfer of file %s has started", basename);
         g_free(basename);
     }
 }
diff --git a/src/channel-playback.c b/src/channel-playback.c
index a124cbb..f5944a7 100644
--- a/src/channel-playback.c
+++ b/src/channel-playback.c
@@ -430,7 +430,7 @@ static void playback_handle_set_latency(SpiceChannel *channel, SpiceMsgIn *in)
     SpiceMsgPlaybackLatency *msg = spice_msg_in_parsed(in);
 
     c->min_latency = msg->latency_ms;
-    SPICE_DEBUG("%s: notify latency update %u", __FUNCTION__, c->min_latency);
+    spice_debug("%s: notify latency update %u", __FUNCTION__, c->min_latency);
     g_coroutine_object_notify(G_OBJECT(channel), "min-latency");
 }
 
@@ -498,6 +498,6 @@ void spice_playback_channel_sync_latency(SpicePlaybackChannel *channel)
 {
     g_return_if_fail(SPICE_IS_PLAYBACK_CHANNEL(channel));
     g_return_if_fail(channel->priv->is_active);
-    SPICE_DEBUG("%s: notify latency update %u", __FUNCTION__, channel->priv->min_latency);
+    spice_debug("%s: notify latency update %u", __FUNCTION__, channel->priv->min_latency);
     g_coroutine_object_notify(G_OBJECT(SPICE_CHANNEL(channel)), "min-latency");
 }
diff --git a/src/decode-glz.c b/src/decode-glz.c
index a5fb6c1..7fb51af 100644
--- a/src/decode-glz.c
+++ b/src/decode-glz.c
@@ -92,7 +92,7 @@ static void glz_decoder_window_resize(SpiceGlzDecoderWindow *w)
     struct glz_image  **new_images;
     int i, new_slot;
 
-    SPICE_DEBUG("%s: array resize %d -> %d", __FUNCTION__,
+    spice_debug("%s: array resize %d -> %d", __FUNCTION__,
                 w->nimages, w->nimages * 2);
     new_images = g_new0(struct glz_image*, w->nimages * 2);
     for (i = 0; i < w->nimages; i++) {
@@ -155,7 +155,7 @@ static void *glz_decoder_window_bits(SpiceGlzDecoderWindow *w, uint64_t id,
     };
 
     if (!g_coroutine_condition_wait(g_coroutine_self(), wait_for_image, &data))
-        SPICE_DEBUG("wait for image cancelled");
+        spice_debug("wait for image cancelled");
 
     int slot = (id - dist) % w->nimages;
 
@@ -368,7 +368,7 @@ static void decode_header(GlibGlzDecoder *d)
     d->image.id = decode_64(d);
     d->image.win_head_dist = decode_32(d);
 
-    SPICE_DEBUG("%s: %dx%d, id %" PRId64 ", ref %" PRId64,
+    spice_debug("%s: %dx%d, id %" PRId64 ", ref %" PRId64,
             __FUNCTION__,
             d->image.width, d->image.height, d->image.id,
             d->image.id - d->image.win_head_dist);
diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
index 6578328..faed363 100644
--- a/src/smartcard-manager.c
+++ b/src/smartcard-manager.c
@@ -268,7 +268,7 @@ static gboolean smartcard_monitor_dispatch(VEvent *event, gpointer user_data)
                 g_warn_if_fail(manager->priv->software_reader == NULL);
                 manager->priv->software_reader = vreader_reference(event->reader);
             }
-            SPICE_DEBUG("smartcard: reader-added");
+            spice_debug("smartcard: reader-added");
             g_signal_emit(G_OBJECT(user_data),
                           signals[SPICE_SMARTCARD_MANAGER_READER_ADDED],
                           0, event->reader);
@@ -280,20 +280,20 @@ static gboolean smartcard_monitor_dispatch(VEvent *event, gpointer user_data)
                 vreader_free(manager->priv->software_reader);
                 manager->priv->software_reader = NULL;
             }
-            SPICE_DEBUG("smartcard: reader-removed");
+            spice_debug("smartcard: reader-removed");
             g_signal_emit(G_OBJECT(user_data),
                           signals[SPICE_SMARTCARD_MANAGER_READER_REMOVED],
                           0, event->reader);
             break;
 
         case VEVENT_CARD_INSERT:
-            SPICE_DEBUG("smartcard: card-inserted");
+            spice_debug("smartcard: card-inserted");
             g_signal_emit(G_OBJECT(user_data),
                           signals[SPICE_SMARTCARD_MANAGER_CARD_INSERTED],
                           0, event->reader);
             break;
         case VEVENT_CARD_REMOVE:
-            SPICE_DEBUG("smartcard: card-removed");
+            spice_debug("smartcard: card-removed");
             g_signal_emit(G_OBJECT(user_data),
                           signals[SPICE_SMARTCARD_MANAGER_CARD_REMOVED],
                           0, event->reader);
@@ -421,7 +421,7 @@ static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args)
     GStrv certificates = NULL;
     gboolean retval = FALSE;
 
-    SPICE_DEBUG("smartcard_manager_init");
+    spice_debug("smartcard_manager_init");
     g_return_val_if_fail(SPICE_IS_SESSION(args->session), FALSE);
     g_object_get(G_OBJECT(args->session),
                  "smartcard-db", &dbname,
@@ -456,7 +456,7 @@ static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args)
         goto end;
 
 init:
-    SPICE_DEBUG("vcard_emul_init");
+    spice_debug("vcard_emul_init");
     emul_init_status = vcard_emul_init(options);
     if ((emul_init_status != VCARD_EMUL_OK)
             && (emul_init_status != VCARD_EMUL_INIT_ALREADY_INITED)) {
@@ -469,7 +469,7 @@ init:
     retval = TRUE;
 
 end:
-    SPICE_DEBUG("smartcard_manager_init end: %d", retval);
+    spice_debug("smartcard_manager_init end: %d", retval);
     g_free(emul_args);
     g_free(dbname);
     g_strfreev(certificates);
@@ -527,7 +527,7 @@ gboolean spice_smartcard_manager_init_finish(SpiceSession *session,
     g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE);
     g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), FALSE);
 
-    SPICE_DEBUG("smartcard_manager_finish");
+    spice_debug("smartcard_manager_finish");
 
     simple = G_SIMPLE_ASYNC_RESULT(result);
     g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == spice_smartcard_manager_init, FALSE);
@@ -699,7 +699,7 @@ void spice_smartcard_manager_init_async(SpiceSession *session,
                                         GAsyncReadyCallback callback,
                                         gpointer opaque)
 {
-    SPICE_DEBUG("using fake smartcard backend");
+    spice_debug("using fake smartcard backend");
 }
 
 G_GNUC_INTERNAL
diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index d60ea73..76a160e 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -41,7 +41,7 @@ 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__)
+    spice_debug("%s: " fmt, SPICE_CHANNEL(channel)->priv->name, ## __VA_ARGS__)
 
 struct _SpiceMsgOut {
     int                   refcount;
diff --git a/src/spice-channel.c b/src/spice-channel.c
index 41c94d0..afeb19a 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -1258,7 +1258,7 @@ error:
        does not linger when closing the socket if the protocol is
        incompatible. Try with the oldest protocol in this case: */
     if (c->link_hdr.major_version != 1) {
-        SPICE_DEBUG("%s: error, switching to protocol 1 (spice 0.4)", c->name);
+        spice_debug("%s: error, switching to protocol 1 (spice 0.4)", c->name);
         c->state = SPICE_CHANNEL_STATE_RECONNECTING;
         g_object_set(c->session, "protocol", 1, NULL);
         return FALSE;
@@ -2753,7 +2753,7 @@ static gboolean test_capability(GArray *caps, guint32 cap)
     c = g_array_index(caps, guint32, word_index);
     ret = (c & (1 << (cap % 32))) != 0;
 
-    SPICE_DEBUG("test cap %d in 0x%X: %s", cap, c, ret ? "yes" : "no");
+    spice_debug("test cap %d in 0x%X: %s", cap, c, ret ? "yes" : "no");
     return ret;
 }
 
diff --git a/src/spice-common.h b/src/spice-common.h
index 8554f4c..edca065 100644
--- a/src/spice-common.h
+++ b/src/spice-common.h
@@ -30,6 +30,7 @@
 #include "common/mem.h"
 #include "common/messages.h"
 #include "common/marshaller.h"
+#include "common/log.h"
 
 #include "spice-util.h"
 
diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index 096fea4..42f3e30 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -89,7 +89,7 @@ static void spice_gstaudio_dispose(GObject *obj)
 {
     SpiceGstaudio *gstaudio = SPICE_GSTAUDIO(obj);
     SpiceGstaudioPrivate *p;
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     p = gstaudio->priv;
 
     stream_dispose(&p->playback);
@@ -147,7 +147,7 @@ static void record_stop(SpiceGstaudio *gstaudio)
 {
     SpiceGstaudioPrivate *p = gstaudio->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     if (p->record.pipe)
         gst_element_set_state(p->record.pipe, GST_STATE_READY);
 }
@@ -280,7 +280,7 @@ static gboolean update_mmtime_timeout_cb(gpointer data)
         gboolean live;
         GstClockTime minlat, maxlat;
         gst_query_parse_latency(q, &live, &minlat, &maxlat);
-        SPICE_DEBUG("got min latency %" GST_TIME_FORMAT ", max latency %"
+        spice_debug("got min latency %" GST_TIME_FORMAT ", max latency %"
                     GST_TIME_FORMAT ", live %d", GST_TIME_ARGS (minlat),
                     GST_TIME_ARGS (maxlat), live);
         spice_playback_channel_set_delay(SPICE_PLAYBACK_CHANNEL(p->pchannel), GST_TIME_AS_MSECONDS(minlat));
@@ -316,7 +316,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
         if (pipeline == NULL)
             pipeline = g_strdup_printf("appsrc is-live=1 do-timestamp=0 caps=\"%s\" name=\"appsrc\" ! queue ! "
                                        "audioconvert ! audioresample ! autoaudiosink name=\"audiosink\"", audio_caps);
-        SPICE_DEBUG("audio pipeline: %s", pipeline);
+        spice_debug("audio pipeline: %s", pipeline);
         p->playback.pipe = gst_parse_launch(pipeline, &error);
         if (error != NULL) {
             g_warning("Failed to create pipeline: %s", error->message);
@@ -383,7 +383,7 @@ static void playback_volume_changed(GObject *object, GParamSpec *pspec, gpointer
     g_return_if_fail(nchannels > 0);
 
     vol = 1.0 * volume[0] / VOLUME_NORMAL;
-    SPICE_DEBUG("playback volume changed to %u (%0.2f)", volume[0], 100*vol);
+    spice_debug("playback volume changed to %u (%0.2f)", volume[0], 100*vol);
 
     if (GST_IS_BIN(p->playback.sink))
         e = gst_bin_get_by_interface(GST_BIN(p->playback.sink), GST_TYPE_STREAM_VOLUME);
@@ -409,7 +409,7 @@ static void playback_mute_changed(GObject *object, GParamSpec *pspec, gpointer d
         return;
 
     g_object_get(object, "mute", &mute, NULL);
-    SPICE_DEBUG("playback mute changed to %u", mute);
+    spice_debug("playback mute changed to %u", mute);
 
     if (GST_IS_BIN(p->playback.sink))
         e = gst_bin_get_by_interface(GST_BIN(p->playback.sink), GST_TYPE_STREAM_VOLUME);
@@ -442,7 +442,7 @@ static void record_volume_changed(GObject *object, GParamSpec *pspec, gpointer d
     g_return_if_fail(nchannels > 0);
 
     vol = 1.0 * volume[0] / VOLUME_NORMAL;
-    SPICE_DEBUG("record volume changed to %u (%0.2f)", volume[0], 100*vol);
+    spice_debug("record volume changed to %u (%0.2f)", volume[0], 100*vol);
 
     /* TODO directsoundsrc doesn't support IDirectSoundBuffer_SetVolume */
     /* TODO pulsesrc doesn't support volume property, it's all coming! */
@@ -471,7 +471,7 @@ static void record_mute_changed(GObject *object, GParamSpec *pspec, gpointer dat
         return;
 
     g_object_get(object, "mute", &mute, NULL);
-    SPICE_DEBUG("record mute changed to %u", mute);
+    spice_debug("record mute changed to %u", mute);
 
     if (GST_IS_BIN(p->record.src))
         e = gst_bin_get_by_interface(GST_BIN(p->record.src), GST_TYPE_STREAM_VOLUME);
@@ -494,11 +494,11 @@ channel_weak_notified(gpointer data,
     SpiceGstaudioPrivate *p = gstaudio->priv;
 
     if (where_the_object_was == (GObject *)p->pchannel) {
-        SPICE_DEBUG("playback closed");
+        spice_debug("playback closed");
         playback_stop(gstaudio);
         p->pchannel = NULL;
     } else if (where_the_object_was == (GObject *)p->rchannel) {
-        SPICE_DEBUG("record closed");
+        spice_debug("record closed");
         record_stop(gstaudio);
         p->rchannel = NULL;
     }
@@ -604,7 +604,7 @@ static gboolean spice_gstaudio_get_playback_volume_info_finish(SpiceAudio *audio
     }
 
     if (p->playback.sink == NULL || p->playback.channels == 0) {
-        SPICE_DEBUG("PlaybackChannel not created yet, force start");
+        spice_debug("PlaybackChannel not created yet, force start");
         /* In order to get system volume, we start the pipeline */
         playback_start(NULL, SPICE_AUDIO_FMT_S16, 2, 48000, audio);
         fake_channel = TRUE;
@@ -626,7 +626,7 @@ static gboolean spice_gstaudio_get_playback_volume_info_finish(SpiceAudio *audio
     g_object_unref(e);
 
     if (fake_channel) {
-        SPICE_DEBUG("Stop faked PlaybackChannel");
+        spice_debug("Stop faked PlaybackChannel");
         playback_stop(SPICE_GSTAUDIO(audio));
     }
 
@@ -643,7 +643,7 @@ static gboolean spice_gstaudio_get_playback_volume_info_finish(SpiceAudio *audio
         *volume = g_new(guint16, p->playback.channels);
         for (i = 0; i < p->playback.channels; i++) {
             (*volume)[i] = (guint16) (vol * VOLUME_NORMAL);
-            SPICE_DEBUG("(playback) volume at %d is %u (%0.2f%%)", i, (*volume)[i], 100*vol);
+            spice_debug("(playback) volume at %d is %u (%0.2f%%)", i, (*volume)[i], 100*vol);
         }
     }
 
@@ -694,7 +694,7 @@ static gboolean spice_gstaudio_get_record_volume_info_finish(SpiceAudio *audio,
     }
 
     if (p->record.src == NULL || p->record.channels == 0) {
-        SPICE_DEBUG("RecordChannel not created yet, force start");
+        spice_debug("RecordChannel not created yet, force start");
         /* In order to get system volume, we start the pipeline */
         record_start(NULL, SPICE_AUDIO_FMT_S16, 2, 48000, audio);
         fake_channel = TRUE;
@@ -716,7 +716,7 @@ static gboolean spice_gstaudio_get_record_volume_info_finish(SpiceAudio *audio,
     g_object_unref(e);
 
     if (fake_channel) {
-        SPICE_DEBUG("Stop faked RecordChannel");
+        spice_debug("Stop faked RecordChannel");
         record_stop(SPICE_GSTAUDIO(audio));
     }
 
@@ -733,7 +733,7 @@ static gboolean spice_gstaudio_get_record_volume_info_finish(SpiceAudio *audio,
         *volume = g_new(guint16, p->record.channels);
         for (i = 0; i < p->record.channels; i++) {
             (*volume)[i] = (guint16) (vol * VOLUME_NORMAL);
-            SPICE_DEBUG("(record) volume at %d is %u (%0.2f%%)", i, (*volume)[i], 100*vol);
+            spice_debug("(record) volume at %d is %u (%0.2f%%)", i, (*volume)[i], 100*vol);
         }
     }
 
diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 9ea28c4..82b3180 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -145,7 +145,7 @@ static guint32 get_keyboard_lock_modifiers(void)
 
     GdkScreen *screen = gdk_screen_get_default();
     if (!GDK_IS_X11_DISPLAY(gdk_screen_get_display(screen))) {
-        SPICE_DEBUG("FIXME: gtk backend is not X11");
+        spice_debug("FIXME: gtk backend is not X11");
         return 0;
     }
 
@@ -597,11 +597,11 @@ static void clipboard_get_targets(GtkClipboard *clipboard,
     selection = get_selection_from_clipboard(s, clipboard);
     g_return_if_fail(selection != -1);
 
-    SPICE_DEBUG("%s:", __FUNCTION__);
+    spice_debug("%s:", __FUNCTION__);
     if (spice_util_get_debug()) {
         for (a = 0; a < n_atoms; a++) {
             name = gdk_atom_name(atoms[a]);
-            SPICE_DEBUG(" \"%s\"", name);
+            spice_debug(" \"%s\"", name);
             g_free(name);
         }
     }
@@ -702,7 +702,7 @@ static void clipboard_got_from_guest(SpiceMainChannel *main, guint selection,
 
     g_return_if_fail(selection == ri->selection);
 
-    SPICE_DEBUG("clipboard got data");
+    spice_debug("clipboard got data");
 
     if (atom2agent[ri->info].vdagent == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
         /* on windows, gtk+ would already convert to LF endings, but
@@ -756,7 +756,7 @@ static void clipboard_get(GtkClipboard *clipboard,
     gulong agent_handler;
     int selection;
 
-    SPICE_DEBUG("clipboard get");
+    spice_debug("clipboard get");
 
     selection = get_selection_from_clipboard(s, clipboard);
     g_return_if_fail(selection != -1);
@@ -782,7 +782,7 @@ static void clipboard_get(GtkClipboard *clipboard,
 
     g_object_get(s->main, "agent-connected", &agent_connected, NULL);
     if (!agent_connected) {
-        SPICE_DEBUG("canceled clipboard_get, before running loop");
+        spice_debug("canceled clipboard_get, before running loop");
         goto cleanup;
     }
 
@@ -801,7 +801,7 @@ cleanup:
 
 static void clipboard_clear(GtkClipboard *clipboard, gpointer user_data)
 {
-    SPICE_DEBUG("clipboard_clear");
+    spice_debug("clipboard_clear");
     /* We watch for clipboard ownership changes and act on those, so we
        don't need to do anything here */
 }
@@ -876,7 +876,7 @@ static gboolean check_clipboard_size_limits(SpiceGtkSession *session,
                   clipboard_len, max_clipboard);
         return FALSE;
     } else if (clipboard_len <= 0) {
-        SPICE_DEBUG("discarding empty clipboard");
+        spice_debug("discarding empty clipboard");
         return FALSE;
     }
 
@@ -1027,7 +1027,7 @@ static void channel_new(SpiceSession *session, SpiceChannel *channel,
     SpiceGtkSessionPrivate *s = self->priv;
 
     if (SPICE_IS_MAIN_CHANNEL(channel)) {
-        SPICE_DEBUG("Changing main channel from %p to %p", s->main, channel);
+        spice_debug("Changing main channel from %p to %p", s->main, channel);
         s->main = SPICE_MAIN_CHANNEL(channel);
         g_signal_connect(channel, "main-clipboard-selection-grab",
                          G_CALLBACK(clipboard_grab), self);
diff --git a/src/spice-pulse.c b/src/spice-pulse.c
index 22db893..36c021c 100644
--- a/src/spice-pulse.c
+++ b/src/spice-pulse.c
@@ -130,7 +130,7 @@ static void spice_pulse_dispose(GObject *obj)
     SpicePulse *pulse = SPICE_PULSE(obj);
     SpicePulsePrivate *p;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     p = pulse->priv;
 
     if (p->playback.uncork_op)
@@ -251,7 +251,7 @@ static void pulse_cork_cb(pa_stream *pastream, int success, void *data)
 {
     struct stream *s = data;
 
-    SPICE_DEBUG("%s: cork started", __FUNCTION__);
+    spice_debug("%s: cork started", __FUNCTION__);
     if (!success)
         g_warning("pulseaudio cork operation failed");
 
@@ -320,7 +320,7 @@ static void stream_underflow_cb(pa_stream *s, void *userdata)
     SpicePulse *pulse = userdata;
     SpicePulsePrivate *p;
 
-    SPICE_DEBUG("PA stream underflow!!");
+    spice_debug("PA stream underflow!!");
 
     p = pulse->priv;
     g_return_if_fail(p != NULL);
@@ -366,10 +366,10 @@ static void stream_update_latency_callback(pa_stream *s, void *userdata)
     spice_playback_channel_set_delay(SPICE_PLAYBACK_CHANNEL(p->pchannel), usec / 1000);
     if (pa_stream_is_corked(p->playback.stream)) {
         if (p->last_delay >= p->target_delay) {
-            SPICE_DEBUG("%s: uncork playback. delay %u target %u",  __FUNCTION__, p->last_delay, p->target_delay);
+            spice_debug("%s: uncork playback. delay %u target %u",  __FUNCTION__, p->last_delay, p->target_delay);
             stream_uncork(pulse, &p->playback);
         } else {
-            SPICE_DEBUG("%s: still corked. delay %u target %u",  __FUNCTION__, p->last_delay, p->target_delay);
+            spice_debug("%s: still corked. delay %u target %u",  __FUNCTION__, p->last_delay, p->target_delay);
         }
     }
 }
@@ -437,7 +437,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
     switch (state) {
     case PA_CONTEXT_READY:
         if (p->state != state) {
-            SPICE_DEBUG("%s: pulse context ready", __FUNCTION__);
+            spice_debug("%s: pulse context ready", __FUNCTION__);
         }
         if (p->playback.stream == NULL) {
             create_playback(pulse);
@@ -446,7 +446,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
         break;
     default:
         if (p->state != state) {
-            SPICE_DEBUG("%s: pulse context not ready (%s)",
+            spice_debug("%s: pulse context not ready (%s)",
                         __FUNCTION__, STATE_NAME(context_state_names, state));
         }
         break;
@@ -468,11 +468,11 @@ static void playback_data(SpicePlaybackChannel *channel,
     state = pa_stream_get_state(p->playback.stream);
     switch (state) {
     case PA_STREAM_CREATING:
-        SPICE_DEBUG("stream creating, dropping data");
+        spice_debug("stream creating, dropping data");
         break;
     case PA_STREAM_READY:
         if (p->playback.state != state) {
-            SPICE_DEBUG("%s: pulse playback stream ready", __FUNCTION__);
+            spice_debug("%s: pulse playback stream ready", __FUNCTION__);
         }
         if (pa_stream_write(p->playback.stream, audio, size, NULL, 0, PA_SEEK_RELATIVE) < 0) {
             g_warning("pa_stream_write() failed: %s",
@@ -481,7 +481,7 @@ static void playback_data(SpicePlaybackChannel *channel,
         break;
     default:
         if (p->playback.state != state) {
-            SPICE_DEBUG("%s: pulse playback stream not ready (%s)",
+            spice_debug("%s: pulse playback stream not ready (%s)",
                         __FUNCTION__, STATE_NAME(stream_state_names, state));
         }
         break;
@@ -493,7 +493,7 @@ static void playback_stop(SpicePulse *pulse)
 {
     SpicePulsePrivate *p = pulse->priv;
 
-    SPICE_DEBUG("%s: #underflow %u", __FUNCTION__, p->playback.num_underflow);
+    spice_debug("%s: #underflow %u", __FUNCTION__, p->playback.num_underflow);
 
     p->playback.started = FALSE;
     if (!p->playback.stream)
@@ -589,7 +589,7 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
     switch (state) {
     case PA_CONTEXT_READY:
         if (p->state != state) {
-            SPICE_DEBUG("%s: pulse context ready", __FUNCTION__);
+            spice_debug("%s: pulse context ready", __FUNCTION__);
         }
         if (p->record.stream == NULL) {
             create_record(pulse);
@@ -610,7 +610,7 @@ static void record_stop(SpicePulse *pulse)
 {
     SpicePulsePrivate *p = pulse->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     p->record.started = FALSE;
     if (!p->record.stream)
@@ -638,7 +638,7 @@ static void playback_volume_changed(GObject *object, GParamSpec *pspec, gpointer
     v.channels = p->playback.spec.channels;
     for (i = 0; i < nchannels; ++i) {
         v.values[i] = (PA_VOLUME_NORM - PA_VOLUME_MUTED) * volume[i] / G_MAXUINT16;
-        SPICE_DEBUG("playback volume changed %u", v.values[i]);
+        spice_debug("playback volume changed %u", v.values[i]);
     }
 
     if (!p->playback.stream ||
@@ -663,7 +663,7 @@ static void playback_mute_changed(GObject *object, GParamSpec *pspec, gpointer d
     pa_operation *op;
 
     g_object_get(object, "mute", &mute, NULL);
-    SPICE_DEBUG("playback mute changed %u", mute);
+    spice_debug("playback mute changed %u", mute);
 
     if (!p->playback.stream ||
         pa_stream_get_index(p->playback.stream) == PA_INVALID_INDEX)
@@ -706,7 +706,7 @@ static void record_mute_changed(GObject *object, GParamSpec *pspec, gpointer dat
     pa_operation *op;
 
     g_object_get(object, "mute", &mute, NULL);
-    SPICE_DEBUG("record mute changed %u", mute);
+    spice_debug("record mute changed %u", mute);
 
     if (!p->record.stream ||
         pa_stream_get_device_index(p->record.stream) == PA_INVALID_INDEX)
@@ -746,7 +746,7 @@ static void record_volume_changed(GObject *object, GParamSpec *pspec, gpointer d
     v.channels = p->record.spec.channels;
     for (i = 0; i < nchannels; ++i) {
         v.values[i] = (PA_VOLUME_NORM - PA_VOLUME_MUTED) * volume[i] / G_MAXUINT16;
-        SPICE_DEBUG("record volume changed %u", v.values[i]);
+        spice_debug("record volume changed %u", v.values[i]);
     }
 
     if (!p->record.stream ||
@@ -776,11 +776,11 @@ channel_weak_notified(gpointer data,
     SpicePulsePrivate *p = pulse->priv;
 
     if (where_the_object_was == (GObject *)p->pchannel) {
-        SPICE_DEBUG("playback closed");
+        spice_debug("playback closed");
         playback_stop(pulse);
         p->pchannel = NULL;
     } else if (where_the_object_was == (GObject *)p->rchannel) {
-        SPICE_DEBUG("record closed");
+        spice_debug("record closed");
         record_stop(pulse);
         p->rchannel = NULL;
     }
@@ -874,7 +874,7 @@ static void context_state_callback(pa_context *c, void *userdata)
 
     case PA_CONTEXT_TERMINATED:
     default:
-        SPICE_DEBUG("PulseAudio context terminated");
+        spice_debug("PulseAudio context terminated");
         goto context_fail;
     }
 
@@ -1034,7 +1034,7 @@ static void spice_pulse_complete_async_task(struct async_task *task, const gchar
     complete_task(task->pulse, task, err_msg);
     if (p->results != NULL) {
         p->results = g_list_remove(p->results, task);
-        SPICE_DEBUG("Number of async task is %d", g_list_length(p->results));
+        spice_debug("Number of async task is %d", g_list_length(p->results));
     }
     free_async_task(task);
 }
@@ -1055,7 +1055,7 @@ static void spice_pulse_complete_all_async_tasks(SpicePulse *pulse, const gchar
     }
     g_list_free(p->results);
     p->results = NULL;
-    SPICE_DEBUG("All async tasks completed");
+    spice_debug("All async tasks completed");
 }
 
 static void stream_restore_read_cb(pa_context *context,
@@ -1088,7 +1088,7 @@ static void stream_restore_read_cb(pa_context *context,
     }
 
     if (info->channel_map.channels == 0) {
-        SPICE_DEBUG("Number of channels stored is zero. Ignore. (%s)", info->name);
+        spice_debug("Number of channels stored is zero. Ignore. (%s)", info->name);
         return;
     }
 
@@ -1191,7 +1191,7 @@ static void pulse_stream_restore_info_async(gboolean is_playback,
     if (is_playback == TRUE &&
             p->playback.stream != NULL &&
             pa_stream_get_index(p->playback.stream) != PA_INVALID_INDEX) {
-        SPICE_DEBUG("Playback stream is created - get-sink-input-info");
+        spice_debug("Playback stream is created - get-sink-input-info");
         p->playback.info_updated = FALSE;
         op = pa_context_get_sink_input_info(p->context,
                                             pa_stream_get_index(p->playback.stream),
@@ -1204,7 +1204,7 @@ static void pulse_stream_restore_info_async(gboolean is_playback,
     } else if (is_playback == FALSE &&
             p->record.stream != NULL &&
             pa_stream_get_index(p->record.stream) != PA_INVALID_INDEX) {
-        SPICE_DEBUG("Record stream is created - get-source-output-info");
+        spice_debug("Record stream is created - get-source-output-info");
         p->record.info_updated = FALSE;
 #if PA_CHECK_VERSION(1,0,0)
         op = pa_context_get_source_output_info(p->context,
@@ -1226,13 +1226,13 @@ static void pulse_stream_restore_info_async(gboolean is_playback,
                 p->record.info.name != NULL) {
             /* If the pstream->info.name is set then we already have updated
              * volume information. We can complete the request now */
-            SPICE_DEBUG("Return the volume-information we already have");
+            spice_debug("Return the volume-information we already have");
             spice_pulse_complete_async_task(task, NULL);
             return;
         }
 
         if (p->results == NULL) {
-            SPICE_DEBUG("Streams are not created - ext-stream-restore");
+            spice_debug("Streams are not created - ext-stream-restore");
             p->playback.info_updated = FALSE;
             p->record.info_updated = FALSE;
 
@@ -1252,7 +1252,7 @@ static void pulse_stream_restore_info_async(gboolean is_playback,
     }
 
     p->results = g_list_append(p->results, task);
-    SPICE_DEBUG ("Number of async task is %d", g_list_length(p->results));
+    spice_debug ("Number of async task is %d", g_list_length(p->results));
     return;
 
 fail:
@@ -1305,7 +1305,7 @@ static gboolean pulse_stream_restore_info_finish(gboolean is_playback,
         *volume = g_new(guint16, pstream->info.channel_map.channels);
         for (i = 0; i < pstream->info.channel_map.channels; i++) {
             (*volume)[i] = MIN(pstream->info.volume.values[i], G_MAXUINT16);
-            SPICE_DEBUG("(%s) volume at channel %d is %u",
+            spice_debug("(%s) volume at channel %d is %u",
                         (is_playback) ? "playback" : "record", i, (*volume)[i]);
         }
     }
diff --git a/src/spice-session.c b/src/spice-session.c
index a36dcea..41710a3 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -283,11 +283,11 @@ static void spice_session_init(SpiceSession *session)
     SpiceSessionPrivate *s;
     gchar *channels;
 
-    SPICE_DEBUG("New session (compiled from package " PACKAGE_STRING ")");
+    spice_debug("New session (compiled from package " PACKAGE_STRING ")");
     s = session->priv = SPICE_SESSION_GET_PRIVATE(session);
 
     channels = spice_channel_supported_string();
-    SPICE_DEBUG("Supported channels: %s", channels);
+    spice_debug("Supported channels: %s", channels);
     g_free(channels);
 
     ring_init(&s->channels);
@@ -331,7 +331,7 @@ spice_session_dispose(GObject *gobject)
     SpiceSession *session = SPICE_SESSION(gobject);
     SpiceSessionPrivate *s = session->priv;
 
-    SPICE_DEBUG("session dispose");
+    spice_debug("session dispose");
 
     session_disconnect(session, FALSE);
 
@@ -1696,7 +1696,7 @@ void spice_session_start_migrating(SpiceSession *session,
 
     g_warn_if_fail(ring_get_length(&s->channels) == ring_get_length(&m->channels));
 
-    SPICE_DEBUG("migration channels left:%d (in migration:%d)",
+    spice_debug("migration channels left:%d (in migration:%d)",
                 ring_get_length(&s->channels), ring_get_length(&m->channels));
     s->migration_left = spice_session_get_channels(session);
 }
@@ -1739,11 +1739,11 @@ void spice_session_abort_migration(SpiceSession *session)
     struct channel *c;
 
     if (s->migration == NULL) {
-        SPICE_DEBUG("no migration in progress");
+        spice_debug("no migration in progress");
         return;
     }
 
-    SPICE_DEBUG("migration: abort");
+    spice_debug("migration: abort");
     if (s->migration_state != SPICE_SESSION_MIGRATION_MIGRATING)
         goto end;
 
@@ -1936,7 +1936,7 @@ void spice_session_disconnect(SpiceSession *session)
 
     s = session->priv;
 
-    SPICE_DEBUG("session: disconnecting %d", s->disconnecting);
+    spice_debug("session: disconnecting %d", s->disconnecting);
     if (s->disconnecting != 0)
         return;
 
@@ -2063,7 +2063,7 @@ static void proxy_lookup_ready(GObject *source_object, GAsyncResult *result,
     GList *addresses = NULL, *it;
     GSocketAddress *address;
 
-    SPICE_DEBUG("proxy lookup ready");
+    spice_debug("proxy lookup ready");
     addresses = g_resolver_lookup_by_name_finish(G_RESOLVER(source_object),
                                                  result, &open_host->error);
     if (addresses == NULL || open_host->error) {
@@ -2116,7 +2116,7 @@ static gboolean open_host_idle_cb(gpointer data)
         GSocketConnectable *address = NULL;
 
         if (s->unix_path) {
-            SPICE_DEBUG("open unix path %s", s->unix_path);
+            spice_debug("open unix path %s", s->unix_path);
 #ifdef G_OS_UNIX
             address = G_SOCKET_CONNECTABLE(g_unix_socket_address_new(s->unix_path));
 #else
@@ -2124,7 +2124,7 @@ static gboolean open_host_idle_cb(gpointer data)
                                 "Unix path unsupported on this platform");
 #endif
         } else {
-            SPICE_DEBUG("open host %s:%d", s->host, open_host->port);
+            spice_debug("open host %s:%d", s->host, open_host->port);
             address = g_network_address_new(s->host, open_host->port);
         }
 
@@ -2139,7 +2139,7 @@ static gboolean open_host_idle_cb(gpointer data)
 
     if (open_host->proxy != NULL) {
         gchar *str = spice_uri_to_string(open_host->proxy);
-        SPICE_DEBUG("(with proxy %s)", str);
+        spice_debug("(with proxy %s)", str);
         g_free(str);
     }
 
@@ -2337,10 +2337,10 @@ void spice_session_set_mm_time(SpiceSession *session, guint32 time)
 
     s->mm_time = time;
     s->mm_time_at_clock = g_get_monotonic_time();
-    SPICE_DEBUG("set mm time: %u", spice_session_get_mm_time(session));
+    spice_debug("set mm time: %u", spice_session_get_mm_time(session));
     if (time > old_time + MM_TIME_DIFF_RESET_THRESH ||
         time < old_time) {
-        SPICE_DEBUG("%s: mm-time-reset, old %u, new %u", __FUNCTION__, old_time, s->mm_time);
+        spice_debug("%s: mm-time-reset, old %u, new %u", __FUNCTION__, old_time, s->mm_time);
         g_coroutine_signal_emit(session, signals[SPICE_SESSION_MM_TIME_RESET], 0);
     }
 }
@@ -2552,7 +2552,7 @@ void spice_session_sync_playback_latency(SpiceSession *session)
         spice_playback_channel_is_active(s->playback_channel)) {
         spice_playback_channel_sync_latency(s->playback_channel);
     } else {
-        SPICE_DEBUG("%s: not implemented when there isn't audio playback", __FUNCTION__);
+        spice_debug("%s: not implemented when there isn't audio playback", __FUNCTION__);
     }
 }
 
@@ -2578,7 +2578,7 @@ guint32 spice_session_get_playback_latency(SpiceSession *session)
         spice_playback_channel_is_active(s->playback_channel)) {
         return spice_playback_channel_get_latency(s->playback_channel);
     } else {
-        SPICE_DEBUG("%s: not implemented when there isn't audio playback", __FUNCTION__);
+        spice_debug("%s: not implemented when there isn't audio playback", __FUNCTION__);
         return 0;
     }
 }
diff --git a/src/spice-util.c b/src/spice-util.c
index 84ed94a..2d0e7c9 100644
--- a/src/spice-util.c
+++ b/src/spice-util.c
@@ -65,7 +65,7 @@ static void spice_util_enable_debug_messages(void)
 void spice_util_set_debug(gboolean enabled)
 {
     /* Make sure debug_once has been initialised
-     * with the value of SPICE_DEBUG already, otherwise
+     * with the value of spice_debug already, otherwise
      * spice_util_get_debug() may overwrite the value
      * that was just set using spice_util_set_debug()
      */
@@ -268,7 +268,7 @@ const gchar* spice_yes_no(gboolean value)
 G_GNUC_INTERNAL
 guint16 spice_make_scancode(guint scancode, gboolean release)
 {
-    SPICE_DEBUG("%s: %s scancode %d",
+    spice_debug("%s: %s scancode %d",
                 __FUNCTION__, release ? "release" : "", scancode);
 
     if (release) {
diff --git a/src/spice-util.h b/src/spice-util.h
index 3f429a0..f902c6e 100644
--- a/src/spice-util.h
+++ b/src/spice-util.h
@@ -18,6 +18,7 @@
 #ifndef SPICE_UTIL_H
 #define SPICE_UTIL_H
 
+#include "common/log.h"
 #include <glib-object.h>
 
 G_BEGIN_DECLS
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 614d93e..1b1cc0f 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -275,7 +275,7 @@ static void update_monitor_area(SpiceDisplay *display)
     GArray *monitors = NULL;
     int i;
 
-    SPICE_DEBUG("update monitor area %d:%d", d->channel_id, d->monitor_id);
+    spice_debug("update monitor area %d:%d", d->channel_id, d->monitor_id);
     if (d->monitor_id < 0)
         goto whole;
 
@@ -288,10 +288,10 @@ static void update_monitor_area(SpiceDisplay *display)
         }
     }
     if (c == NULL) {
-        SPICE_DEBUG("update monitor: no monitor %d", d->monitor_id);
+        spice_debug("update monitor: no monitor %d", d->monitor_id);
         set_monitor_ready(display, false);
         if (spice_channel_test_capability(d->display, SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
-            SPICE_DEBUG("waiting until MonitorsConfig is received");
+            spice_debug("waiting until MonitorsConfig is received");
             g_clear_pointer(&monitors, g_array_unref);
             return;
         }
@@ -387,7 +387,7 @@ static void spice_display_set_property(GObject      *object,
             if (env != NULL)
                 delay = strtoul(env, NULL, 10);
 
-            SPICE_DEBUG("keypress-delay is set to %u ms", delay);
+            spice_debug("keypress-delay is set to %u ms", delay);
             d->keypress_delay = delay;
         }
         break;
@@ -424,7 +424,7 @@ static void spice_display_dispose(GObject *obj)
     SpiceDisplay *display = SPICE_DISPLAY(obj);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("spice display dispose");
+    spice_debug("spice display dispose");
 
     spicex_image_destroy(display);
     g_clear_object(&d->session);
@@ -443,7 +443,7 @@ static void spice_display_finalize(GObject *obj)
     SpiceDisplay *display = SPICE_DISPLAY(obj);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("Finalize spice display");
+    spice_debug("Finalize spice display");
 
     if (d->grabseq) {
         spice_grab_sequence_free(d->grabseq);
@@ -472,7 +472,7 @@ static void spice_display_finalize(GObject *obj)
 
 static GdkCursor* get_blank_cursor(void)
 {
-    if (g_getenv("SPICE_DEBUG_CURSOR"))
+    if (g_getenv("spice_debug_CURSOR"))
         return gdk_cursor_new(GDK_DOT);
 
     return gdk_cursor_new(GDK_BLANK_CURSOR);
@@ -481,7 +481,7 @@ static GdkCursor* get_blank_cursor(void)
 static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,
                             gpointer user_data G_GNUC_UNUSED)
 {
-    SPICE_DEBUG("%s (implicit: %d, keyboard: %d)", __FUNCTION__,
+    spice_debug("%s (implicit: %d, keyboard: %d)", __FUNCTION__,
                 event->implicit, event->keyboard);
 
     if (event->keyboard) {
@@ -516,7 +516,7 @@ static void drag_data_received_callback(SpiceDisplay *self,
     /* We get a buf like:
      * file:///root/a.txt\r\nfile:///root/b.txt\r\n
      */
-    SPICE_DEBUG("%s: drag a file", __FUNCTION__);
+    spice_debug("%s: drag a file", __FUNCTION__);
     buf = gtk_selection_data_get_data(data);
     g_return_if_fail(buf != NULL);
 
@@ -540,7 +540,7 @@ static void drag_data_received_callback(SpiceDisplay *self,
 
 static void grab_notify(SpiceDisplay *display, gboolean was_grabbed)
 {
-    SPICE_DEBUG("grab notify %d", was_grabbed);
+    spice_debug("grab notify %d", was_grabbed);
 
     if (was_grabbed == FALSE)
         release_keys(display);
@@ -747,7 +747,7 @@ static void try_keyboard_grab(SpiceDisplay *display)
 
     g_return_if_fail(gtk_widget_is_focus(widget));
 
-    SPICE_DEBUG("grab keyboard");
+    spice_debug("grab keyboard");
     gtk_widget_grab_focus(widget);
 
 #ifdef G_OS_WIN32
@@ -775,7 +775,7 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
     if (!d->keyboard_grab_active)
         return;
 
-    SPICE_DEBUG("ungrab keyboard");
+    spice_debug("ungrab keyboard");
     gdk_keyboard_ungrab(GDK_CURRENT_TIME);
 #ifdef G_OS_WIN32
     if (d->keyboard_hook != NULL) {
@@ -807,7 +807,7 @@ static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
     GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
 
     if (!GDK_IS_X11_DISPLAY(gdk_window_get_display(w))) {
-        SPICE_DEBUG("FIXME: gtk backend is not X11");
+        spice_debug("FIXME: gtk backend is not X11");
         return;
     }
 
@@ -821,7 +821,7 @@ static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
                            &d->x11_accel_numerator, &d->x11_accel_denominator, &d->x11_threshold);
         /* set mouse acceleration to default */
         XChangePointerControl(x_display, True, True, -1, -1, -1);
-        SPICE_DEBUG("disabled X11 mouse motion %d %d %d",
+        spice_debug("disabled X11 mouse motion %d %d %d",
                     d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
     }
 #elif defined GDK_WINDOWING_WIN32
@@ -865,7 +865,7 @@ static gboolean win32_clip_cursor(void)
         return false;
     }
 
-    SPICE_DEBUG("clip rect %ld %ld %ld %ld\n",
+    spice_debug("clip rect %ld %ld %ld %ld\n",
                 rect.left, rect.right, rect.top, rect.bottom);
 
     if (!ClipCursor(&rect))
@@ -1070,7 +1070,7 @@ static void recalc_geometry(GtkWidget *widget)
     if (spicex_is_scaled(display))
         zoom = (gdouble)d->zoom_level / 100;
 
-    SPICE_DEBUG("recalc geom monitor: %d:%d, guest +%d+%d:%dx%d, window %dx%d, zoom %g",
+    spice_debug("recalc geom monitor: %d:%d, guest +%d+%d:%dx%d, window %dx%d, zoom %g",
                 d->channel_id, d->monitor_id, d->area.x, d->area.y, d->area.width, d->area.height,
                 d->ww, d->wh, zoom);
 
@@ -1270,7 +1270,7 @@ static void release_keys(SpiceDisplay *display)
     SpiceDisplayPrivate *d = display->priv;
     uint32_t i, b;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     for (i = 0; i < SPICE_N_ELEMENTS(d->key_state); i++) {
         if (!d->key_state[i]) {
             continue;
@@ -1354,7 +1354,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
     }
 
 #endif
-    SPICE_DEBUG("%s %s: keycode: %d  state: %d  group %d modifier %d",
+    spice_debug("%s %s: keycode: %d  state: %d  group %d modifier %d",
             __FUNCTION__, key->type == GDK_KEY_PRESS ? "press" : "release",
             key->hardware_keycode, key->state, key->group, key->is_modifier);
 
@@ -1445,7 +1445,7 @@ void spice_display_send_keys(SpiceDisplay *display, const guint *keyvals,
     g_return_if_fail(SPICE_IS_DISPLAY(display));
     g_return_if_fail(keyvals != NULL);
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     if (kind & SPICE_DISPLAY_KEY_EVENT_PRESS) {
         for (i = 0 ; i < nkeyvals ; i++)
@@ -1463,7 +1463,7 @@ static gboolean enter_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     d->mouse_have_pointer = true;
     spice_gtk_session_set_mouse_has_pointer(d->gtk_session, true);
@@ -1478,7 +1478,7 @@ static gboolean leave_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     if (d->mouse_grab_active)
         return true;
@@ -1495,7 +1495,7 @@ static gboolean focus_in_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UN
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     /*
      * Ignore focus in when we already have the focus
@@ -1523,7 +1523,7 @@ static gboolean focus_out_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_U
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
     update_display(NULL);
 
     /*
@@ -1661,7 +1661,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = display->priv;
 
-    SPICE_DEBUG("%s", __FUNCTION__);
+    spice_debug("%s", __FUNCTION__);
 
     if (!d->inputs)
         return true;
@@ -1673,7 +1673,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
     else if (scroll->direction == GDK_SCROLL_DOWN)
         button = SPICE_MOUSE_BUTTON_DOWN;
     else {
-        SPICE_DEBUG("unsupported scroll direction");
+        spice_debug("unsupported scroll direction");
         return true;
     }
 
@@ -1690,7 +1690,7 @@ static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
     SpiceDisplayPrivate *d = display->priv;
     int x, y;
 
-    SPICE_DEBUG("%s %s: button %d, state 0x%x", __FUNCTION__,
+    spice_debug("%s %s: button %d, state 0x%x", __FUNCTION__,
             button->type == GDK_BUTTON_PRESS ? "press" : "release",
             button->button, button->state);
 
@@ -2101,7 +2101,7 @@ static void update_mouse_mode(SpiceChannel *channel, gpointer data)
     GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
 
     g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
-    SPICE_DEBUG("mouse mode %d", d->mouse_mode);
+    spice_debug("mouse mode %d", d->mouse_mode);
 
     switch (d->mouse_mode) {
     case SPICE_MOUSE_MODE_CLIENT:
@@ -2143,10 +2143,10 @@ static void update_area(SpiceDisplay *display,
         .height = height
     };
 
-    SPICE_DEBUG("update area, primary: %dx%d, area: +%d+%d %dx%d", d->width, d->height, area.x, area.y, area.width, area.height);
+    spice_debug("update area, primary: %dx%d, area: +%d+%d %dx%d", d->width, d->height, area.x, area.y, area.width, area.height);
 
     if (!gdk_rectangle_intersect(&primary, &area, &area)) {
-        SPICE_DEBUG("The monitor area is not intersecting primary surface");
+        spice_debug("The monitor area is not intersecting primary surface");
         memset(&d->area, '\0', sizeof(d->area));
         set_monitor_ready(display, false);
         return;
@@ -2237,7 +2237,7 @@ static void mark(SpiceDisplay *display, gint mark)
     SpiceDisplayPrivate *d = display->priv;
     g_return_if_fail(d != NULL);
 
-    SPICE_DEBUG("widget mark: %d, %d:%d %p", mark, d->channel_id, d->monitor_id, display);
+    spice_debug("widget mark: %d, %d:%d %p", mark, d->channel_id, d->monitor_id, display);
     d->mark = mark;
     update_ready(display);
 }
@@ -2411,11 +2411,11 @@ static void cursor_reset(SpiceCursorChannel *channel, gpointer data)
     GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
 
     if (!window) {
-        SPICE_DEBUG("%s: no window, returning",  __FUNCTION__);
+        spice_debug("%s: no window, returning",  __FUNCTION__);
         return;
     }
 
-    SPICE_DEBUG("%s",  __FUNCTION__);
+    spice_debug("%s",  __FUNCTION__);
     gdk_window_set_cursor(window, NULL);
 }
 
@@ -2498,7 +2498,7 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
     int id;
 
     g_object_get(channel, "channel-id", &id, NULL);
-    SPICE_DEBUG("channel_destroy %d", id);
+    spice_debug("channel_destroy %d", id);
 
     if (SPICE_IS_MAIN_CHANNEL(channel)) {
         d->main = NULL;
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index c62f56e..b4b1acd 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -243,7 +243,7 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
 #ifdef G_OS_WIN32
     priv->installer = spice_win_usb_driver_new(err);
     if (!priv->installer) {
-        SPICE_DEBUG("failed to initialize winusb driver");
+        spice_debug("failed to initialize winusb driver");
         return FALSE;
     }
 #endif
@@ -425,7 +425,7 @@ static void spice_usb_device_manager_set_property(GObject       *gobject,
             break;
         }
 
-        SPICE_DEBUG("auto-connect filter set to %s", filter);
+        spice_debug("auto-connect filter set to %s", filter);
         free(priv->auto_conn_filter_rules);
         priv->auto_conn_filter_rules = rules;
         priv->auto_conn_filter_rules_count = count;
@@ -450,7 +450,7 @@ static void spice_usb_device_manager_set_property(GObject       *gobject,
             break;
         }
 
-        SPICE_DEBUG("redirect-on-connect filter set to %s", filter);
+        spice_debug("redirect-on-connect filter set to %s", filter);
         free(priv->redirect_on_connect_rules);
         priv->redirect_on_connect_rules = rules;
         priv->redirect_on_connect_rules_count = count;
@@ -785,7 +785,7 @@ static void spice_usb_device_manager_auto_connect_cb(GObject      *gobject,
         g_prefix_error(&err, "Could not auto-redirect %s: ", desc);
         g_free(desc);
 
-        SPICE_DEBUG("%s", err->message);
+        spice_debug("%s", err->message);
         g_signal_emit(self, signals[AUTO_CONNECT_FAILED], 0, device, err);
         g_error_free(err);
     }
@@ -889,7 +889,7 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
                                    spice_usb_device_ref(device));
     }
 
-    SPICE_DEBUG("device added %04x:%04x (%p)",
+    spice_debug("device added %04x:%04x (%p)",
                 spice_usb_device_get_vid(device),
                 spice_usb_device_get_pid(device),
                 device);
@@ -913,7 +913,7 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager *self,
     const guint8 state = spice_usb_device_get_state(device);
     if ((state == SPICE_USB_DEVICE_STATE_INSTALLING) ||
         (state == SPICE_USB_DEVICE_STATE_UNINSTALLING)) {
-        SPICE_DEBUG("skipping " DEV_ID_FMT ". It is un/installing its driver",
+        spice_debug("skipping " DEV_ID_FMT ". It is un/installing its driver",
                     bus, address);
         return;
     }
@@ -921,7 +921,7 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager *self,
 
     spice_usb_device_manager_disconnect_device(self, device);
 
-    SPICE_DEBUG("device removed %04x:%04x (%p)",
+    spice_debug("device removed %04x:%04x (%p)",
                 spice_usb_device_get_vid(device),
                 spice_usb_device_get_pid(device),
                 device);
@@ -953,7 +953,7 @@ static void spice_usb_device_manager_add_udev(SpiceUsbDeviceManager  *self,
 
     device = spice_usb_device_manager_find_device(self, bus, address);
     if (device) {
-        SPICE_DEBUG("USB device 0x%04x:0x%04x at %d.%d already exists, ignored",
+        spice_debug("USB device 0x%04x:0x%04x at %d.%d already exists, ignored",
                     spice_usb_device_get_vid(device),
                     spice_usb_device_get_pid(device),
                     spice_usb_device_get_busnum(device),
@@ -1119,7 +1119,7 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject,
     g_return_if_fail(SPICE_IS_WIN_USB_DRIVER(installer));
     g_return_if_fail(device!= NULL);
 
-    SPICE_DEBUG("Win USB driver install finished");
+    spice_debug("Win USB driver install finished");
 
     if (!spice_win_usb_driver_install_finish(installer, res, &err)) {
         g_warning("win usb driver install failed -- %s", err->message);
@@ -1146,7 +1146,7 @@ static void spice_usb_device_manager_drv_uninstall_cb(GObject *gobject,
     SpiceUsbDeviceManager *self = cbinfo->manager;
     GError *err = NULL;
 
-    SPICE_DEBUG("Win USB driver uninstall finished");
+    spice_debug("Win USB driver uninstall finished");
     g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self));
 
     if (!spice_win_usb_driver_uninstall_finish(cbinfo->installer, res, &err)) {
@@ -1406,7 +1406,7 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
     g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self));
     g_return_if_fail(device != NULL);
 
-    SPICE_DEBUG("connecting device %p", device);
+    spice_debug("connecting device %p", device);
 
     result = g_simple_async_result_new(G_OBJECT(self), callback, user_data,
                                spice_usb_device_manager_connect_device_async);
@@ -1436,7 +1436,7 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
              * time, and its remove-device event was ignored.
              * So remove the device now
              */
-            SPICE_DEBUG("libdev does not exist for %p -- removing", device);
+            spice_debug("libdev does not exist for %p -- removing", device);
             spice_usb_device_ref(device);
             g_ptr_array_remove(priv->devices, device);
             g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
@@ -1557,7 +1557,7 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
     g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self));
     g_return_if_fail(device != NULL);
 
-    SPICE_DEBUG("disconnecting device %p", device);
+    spice_debug("disconnecting device %p", device);
 
 #ifdef USE_USBREDIR
     SpiceUsbredirChannel *channel;
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index fe983c9..f0cff7b 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -445,7 +445,7 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
         g_prefix_error(&err, "Could not redirect %s: ", desc);
         g_free(desc);
 
-        SPICE_DEBUG("%s", err->message);
+        spice_debug("%s", err->message);
         g_signal_emit(self, signals[CONNECT_FAILED], 0, device, err);
         g_error_free(err);
 
diff --git a/src/usbutil.c b/src/usbutil.c
index 16d757b..38ac921 100644
--- a/src/usbutil.c
+++ b/src/usbutil.c
@@ -234,7 +234,7 @@ static gboolean spice_usbutil_load_usbids(void)
         for (i = 0; dirs[i]; ++i) {
             path = g_build_filename(dirs[i], "hwdata", "usb.ids", NULL);
             success = spice_usbutil_parse_usbids(path);
-            SPICE_DEBUG("loading %s success: %s", path, spice_yes_no(success));
+            spice_debug("loading %s success: %s", path, spice_yes_no(success));
             g_free(path);
 
             if (success)
diff --git a/src/vmcstream.c b/src/vmcstream.c
index 483dd5a..8f40b92 100644
--- a/src/vmcstream.c
+++ b/src/vmcstream.c
@@ -118,7 +118,7 @@ spice_vmc_input_stream_co_data(SpiceVmcInputStream *self,
     self->coroutine = coroutine_self();
 
     while (size > 0) {
-        SPICE_DEBUG("spicevmc co_data %p", self->result);
+        spice_debug("spicevmc co_data %p", self->result);
         if (!self->result)
             coroutine_yield(NULL);
 
@@ -130,7 +130,7 @@ spice_vmc_input_stream_co_data(SpiceVmcInputStream *self,
         size -= min;
         data += min;
 
-        SPICE_DEBUG("spicevmc co_data complete: %" G_GSIZE_FORMAT
+        spice_debug("spicevmc co_data complete: %" G_GSIZE_FORMAT
                     "/%" G_GSIZE_FORMAT, min, self->count);
 
         self->pos += min;
@@ -158,7 +158,7 @@ read_cancelled(GCancellable *cancellable,
 {
     SpiceVmcInputStream *self = SPICE_VMC_INPUT_STREAM(user_data);
 
-    SPICE_DEBUG("read cancelled, %p", self->result);
+    spice_debug("read cancelled, %p", self->result);
     g_simple_async_result_set_error(self->result,
                                     G_IO_ERROR, G_IO_ERROR_CANCELLED,
                                     "read cancelled");
@@ -319,7 +319,7 @@ spice_vmc_input_stream_close(GInputStream  *stream,
                              GCancellable  *cancellable,
                              GError       **error)
 {
-    SPICE_DEBUG("fake close");
+    spice_debug("fake close");
     return TRUE;
 }
 
@@ -410,7 +410,7 @@ spice_vmc_output_stream_write_finish(GOutputStream *stream,
     GSimpleAsyncResult *res =
         g_simple_async_result_get_op_res_gpointer(G_SIMPLE_ASYNC_RESULT(simple));
 
-    SPICE_DEBUG("spicevmc write finish");
+    spice_debug("spicevmc write finish");
     return spice_vmc_write_finish(self->channel, G_ASYNC_RESULT(res), error);
 }
 
@@ -439,7 +439,7 @@ spice_vmc_output_stream_write_async(GOutputStream *stream,
     SpiceVmcOutputStream *self = SPICE_VMC_OUTPUT_STREAM(stream);
     GSimpleAsyncResult *simple;
 
-    SPICE_DEBUG("spicevmc write async");
+    spice_debug("spicevmc write async");
     /* an AsyncResult to forward async op to channel */
     simple = g_simple_async_result_new(G_OBJECT(self), callback, user_data,
                                        spice_vmc_output_stream_write_async);
diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
index 6bf351f..1651618 100644
--- a/src/vncdisplaykeymap.c
+++ b/src/vncdisplaykeymap.c
@@ -19,7 +19,7 @@
 
 #undef G_LOG_DOMAIN
 #define G_LOG_DOMAIN "vnc-keymap"
-#define VNC_DEBUG(message) SPICE_DEBUG(message);
+#define VNC_DEBUG(message) spice_debug(message);
 
 /*
  * This table is taken from QEMU x_keymap.c, under the terms:
diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 1e4b2d6..e02ad9c 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -352,7 +352,7 @@ static void handle_dev_change(GUdevClient *self)
                                            __FUNCTION__);
     g_return_if_fail(dev_count >= 0);
 
-    SPICE_DEBUG("number of current devices %"G_GSSIZE_FORMAT
+    spice_debug("number of current devices %"G_GSSIZE_FORMAT
                 ", I know about %"G_GSSIZE_FORMAT" devices",
                 dev_count, priv->udev_list_size);
 
@@ -517,7 +517,7 @@ static void g_udev_device_print(GUdevDevice *udev, const gchar *msg)
     udevinfo = udev->priv->udevinfo;
     g_return_if_fail(udevinfo != NULL);
 
-    SPICE_DEBUG("%s: %d.%d 0x%04x:0x%04x class %d", msg,
+    spice_debug("%s: %d.%d 0x%04x:0x%04x class %d", msg,
                 udevinfo->bus, udevinfo->addr,
                 udevinfo->vid, udevinfo->pid, udevinfo->class);
 }
diff --git a/src/win-usb-driver-install.c b/src/win-usb-driver-install.c
index 54e9b14..69d4e0f 100644
--- a/src/win-usb-driver-install.c
+++ b/src/win-usb-driver-install.c
@@ -68,7 +68,7 @@ static gboolean spice_win_usb_driver_initable_init(GInitable     *initable,
     SpiceWinUsbDriver *self = SPICE_WIN_USB_DRIVER(initable);
     SpiceWinUsbDriverPrivate *priv = self->priv;
 
-    SPICE_DEBUG("win-usb-driver-install: connecting to usbclerk named pipe");
+    spice_debug("win-usb-driver-install: connecting to usbclerk named pipe");
     priv->handle = CreateFile(USB_CLERK_PIPE_NAME,
                               GENERIC_READ | GENERIC_WRITE,
                               0, NULL,
@@ -136,7 +136,7 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
 
     bytes = g_input_stream_read_finish(istream, read_res, &err);
 
-    SPICE_DEBUG("Finished reading reply-msg from usbclerk: bytes=%ld "
+    spice_debug("Finished reading reply-msg from usbclerk: bytes=%ld "
                 "err_exist?=%d", (long)bytes, err!=NULL);
 
     g_warn_if_fail(g_input_stream_close(istream, NULL, NULL));
@@ -229,7 +229,7 @@ gboolean spice_win_usb_driver_send_request(SpiceWinUsbDriver *self, guint16 op,
     gsize bytes;
     gboolean ret;
 
-    SPICE_DEBUG("sending a request to usbclerk service (op=%d vid=0x%04x pid=0x%04x",
+    spice_debug("sending a request to usbclerk service (op=%d vid=0x%04x pid=0x%04x",
                 op, vid, pid);
 
     g_return_val_if_fail(SPICE_IS_WIN_USB_DRIVER(self), FALSE);
@@ -248,7 +248,7 @@ gboolean spice_win_usb_driver_send_request(SpiceWinUsbDriver *self, guint16 op,
     ret = g_output_stream_write_all(ostream, &req, sizeof(req), &bytes, NULL, err);
     g_warn_if_fail(g_output_stream_close(ostream, NULL, NULL));
     g_object_unref(ostream);
-    SPICE_DEBUG("write_all request returned %d written bytes %"G_GSIZE_FORMAT
+    spice_debug("write_all request returned %d written bytes %"G_GSIZE_FORMAT
                 " expecting %"G_GSIZE_FORMAT,
                 ret, bytes, sizeof(req));
     return ret;
@@ -263,7 +263,7 @@ void spice_win_usb_driver_read_reply_async(SpiceWinUsbDriver *self)
     g_return_if_fail(SPICE_IS_WIN_USB_DRIVER(self));
     priv = self->priv;
 
-    SPICE_DEBUG("waiting for a reply from usbclerk");
+    spice_debug("waiting for a reply from usbclerk");
 
     istream = g_win32_input_stream_new(priv->handle, FALSE);
 
@@ -379,7 +379,7 @@ void spice_win_usb_driver_install_async(SpiceWinUsbDriver *self,
                                         GAsyncReadyCallback callback,
                                         gpointer user_data)
 {
-    SPICE_DEBUG("Win usb driver installation started");
+    spice_debug("Win usb driver installation started");
 
     spice_win_usb_driver_op(self, device, USB_CLERK_DRIVER_SESSION_INSTALL,
                             cancellable, callback, user_data);
@@ -392,7 +392,7 @@ void spice_win_usb_driver_uninstall_async(SpiceWinUsbDriver *self,
                                           GAsyncReadyCallback callback,
                                           gpointer user_data)
 {
-    SPICE_DEBUG("Win usb driver uninstall operation started");
+    spice_debug("Win usb driver uninstall operation started");
 
     spice_win_usb_driver_op(self, device, USB_CLERK_DRIVER_REMOVE, cancellable,
                             callback, user_data);
-- 
2.5.0



More information about the Spice-devel mailing list