[Spice-devel] [spice-gtk v3 07/19] log: use glib logging on testing tools

Victor Toso victortoso at redhat.com
Sat Mar 12 14:32:08 UTC 2016


---
 src/spicy-connect.c    |  2 +-
 src/spicy-screenshot.c | 10 +++++-----
 src/spicy-stats.c      | 12 ++++++------
 src/spicy.c            | 34 +++++++++++++++++-----------------
 4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/spicy-connect.c b/src/spicy-connect.c
index c471df5..125848c 100644
--- a/src/spicy-connect.c
+++ b/src/spicy-connect.c
@@ -173,7 +173,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
         connect_entries[i].entry = GTK_WIDGET(gtk_entry_new());
         gtk_table_attach_defaults(table, connect_entries[i].entry, 1, 2, i, i+1);
         g_object_get(session, connect_entries[i].prop, &txt, NULL);
-        SPICE_DEBUG("%s: #%i [%s]: \"%s\"",
+        g_debug("%s: #%i [%s]: \"%s\"",
                 __FUNCTION__, i, connect_entries[i].prop, txt);
         if (txt) {
             gtk_entry_set_text(GTK_ENTRY(connect_entries[i].entry), txt);
diff --git a/src/spicy-screenshot.c b/src/spicy-screenshot.c
index 63666d6..358fcf3 100644
--- a/src/spicy-screenshot.c
+++ b/src/spicy-screenshot.c
@@ -39,7 +39,7 @@ static void primary_create(SpiceChannel *channel, gint format,
                            gint width, gint height, gint stride,
                            gint shmid, gpointer imgdata, gpointer data)
 {
-    SPICE_DEBUG("%s: %dx%d, format %d", __FUNCTION__, width, height, format);
+    g_debug("%s: %dx%d, format %d", __FUNCTION__, width, height, format);
     d_format = format;
     d_width  = width;
     d_height = height;
@@ -55,7 +55,7 @@ static int write_ppm_32(void)
 
     fp = fopen(outf,"w");
     if (NULL == fp) {
-	fprintf(stderr, "%s: can't open %s: %s\n", g_get_prgname(), outf, strerror(errno));
+	g_printerr("%s: can't open %s: %s\n", g_get_prgname(), outf, strerror(errno));
 	return -1;
     }
     fprintf(fp, "P6\n%d %d\n255\n",
@@ -89,12 +89,12 @@ static void invalidate(SpiceChannel *channel,
         rc = write_ppm_32();
         break;
     default:
-        fprintf(stderr, "unsupported spice surface format %d\n", d_format);
+        g_printerr("unsupported spice surface format %d\n", d_format);
         rc = -1;
         break;
     }
     if (rc == 0)
-        fprintf(stderr, "wrote screen shot to %s\n", outf);
+        g_printerr("wrote screen shot to %s\n", outf);
     g_main_loop_quit(mainloop);
 }
 
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
     spice_cmdline_session_setup(session);
 
     if (!spice_session_connect(session)) {
-        fprintf(stderr, "spice_session_connect failed\n");
+        g_printerr("spice_session_connect failed\n");
         exit(1);
     }
 
diff --git a/src/spicy-stats.c b/src/spicy-stats.c
index d8a4706..314836d 100644
--- a/src/spicy-stats.c
+++ b/src/spicy-stats.c
@@ -46,7 +46,7 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer *data)
     int id;
 
     if (SPICE_IS_MAIN_CHANNEL(channel)) {
-        SPICE_DEBUG("new main channel");
+        g_debug("new main channel");
         g_signal_connect(channel, "channel-event",
                          G_CALLBACK(main_channel_event), data);
     }
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
     spice_cmdline_session_setup(session);
 
     if (!spice_session_connect(session)) {
-        fprintf(stderr, "spice_session_connect failed\n");
+        g_printerr("spice_session_connect failed\n");
         exit(1);
     }
 
@@ -123,15 +123,15 @@ int main(int argc, char *argv[])
         GList *iter, *list = spice_session_get_channels(session);
         gulong total_read_bytes;
         gint  channel_type;
-        printf("total bytes read:\n");
+        g_print("total bytes read:\n");
         for (iter = list ; iter ; iter = iter->next) {
             g_object_get(iter->data,
                 "total-read-bytes", &total_read_bytes,
                 "channel-type", &channel_type,
                 NULL);
-            printf("%s: %lu\n",
-                   spice_channel_type_to_string(channel_type),
-                   total_read_bytes);
+            g_print("%s: %lu\n",
+                    spice_channel_type_to_string(channel_type),
+                    total_read_bytes);
         }
         g_list_free(list);
     }
diff --git a/src/spicy.c b/src/spicy.c
index 12ae653..3aceb02 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -404,7 +404,7 @@ static void menu_cb_bool_prop(GtkToggleAction *action, gpointer data)
     gpointer object;
 
     name = gtk_action_get_name(GTK_ACTION(action));
-    SPICE_DEBUG("%s: %s = %s", __FUNCTION__, name, state ? "yes" : "no");
+    g_debug("%s: %s = %s", __FUNCTION__, name, state ? "yes" : "no");
 
     g_key_file_set_boolean(keyfile, "general", name, state);
 
@@ -1113,7 +1113,7 @@ static void destroy_spice_window(SpiceWindow *win)
     if (win == NULL)
         return;
 
-    SPICE_DEBUG("destroy window (#%d:%d)", win->id, win->monitor_id);
+    g_debug("destroy window (#%d:%d)", win->id, win->monitor_id);
     g_object_unref(win->ag);
     g_object_unref(win->ui);
     gtk_widget_destroy(win->toplevel);
@@ -1133,7 +1133,7 @@ static void recent_add(SpiceSession *session)
     char *uri;
 
     g_object_get(session, "uri", &uri, NULL);
-    SPICE_DEBUG("%s: %s", __FUNCTION__, uri);
+    g_debug("%s: %s", __FUNCTION__, uri);
 
     recent = gtk_recent_manager_get_default();
     if (g_str_has_prefix(uri, "spice://"))
@@ -1304,7 +1304,7 @@ static void add_window(spice_connection *conn, SpiceWindow *win)
     g_return_if_fail(win->monitor_id < MONITORID_MAX);
     g_return_if_fail(conn->wins[win->id * CHANNELID_MAX + win->monitor_id] == NULL);
 
-    SPICE_DEBUG("add display monitor %d:%d", win->id, win->monitor_id);
+    g_debug("add display monitor %d:%d", win->id, win->monitor_id);
     conn->wins[win->id * CHANNELID_MAX + win->monitor_id] = win;
 }
 
@@ -1602,10 +1602,10 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
 
     g_object_get(channel, "channel-id", &id, NULL);
     conn->channels++;
-    SPICE_DEBUG("new channel (#%d)", id);
+    g_debug("new channel (#%d)", id);
 
     if (SPICE_IS_MAIN_CHANNEL(channel)) {
-        SPICE_DEBUG("new main channel");
+        g_debug("new main channel");
         conn->main = SPICE_MAIN_CHANNEL(channel);
         g_signal_connect(channel, "channel-event",
                          G_CALLBACK(main_channel_event), conn);
@@ -1624,20 +1624,20 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
             return;
         if (conn->wins[id] != NULL)
             return;
-        SPICE_DEBUG("new display channel (#%d)", id);
+        g_debug("new display channel (#%d)", id);
         g_signal_connect(channel, "notify::monitors",
                          G_CALLBACK(display_monitors), conn);
         spice_channel_connect(channel);
     }
 
     if (SPICE_IS_INPUTS_CHANNEL(channel)) {
-        SPICE_DEBUG("new inputs channel");
+        g_debug("new inputs channel");
         g_signal_connect(channel, "inputs-modifiers",
                          G_CALLBACK(inputs_modifiers), conn);
     }
 
     if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
-        SPICE_DEBUG("new audio channel");
+        g_debug("new audio channel");
         conn->audio = spice_audio_get(s, NULL);
     }
 
@@ -1661,19 +1661,19 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
 
     g_object_get(channel, "channel-id", &id, NULL);
     if (SPICE_IS_MAIN_CHANNEL(channel)) {
-        SPICE_DEBUG("zap main channel");
+        g_debug("zap main channel");
         conn->main = NULL;
     }
 
     if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
         if (id >= SPICE_N_ELEMENTS(conn->wins))
             return;
-        SPICE_DEBUG("zap display channel (#%d)", id);
+        g_debug("zap display channel (#%d)", id);
         /* FIXME destroy widget only */
     }
 
     if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
-        SPICE_DEBUG("zap audio channel");
+        g_debug("zap audio channel");
     }
 
     if (SPICE_IS_USBREDIR_CHANNEL(channel)) {
@@ -1730,7 +1730,7 @@ static spice_connection *connection_new(void)
                                             g_object_unref,
                                             (GDestroyNotify)transfer_task_widgets_free);
     connections++;
-    SPICE_DEBUG("%s (%d)", __FUNCTION__, connections);
+    g_debug("%s (%d)", __FUNCTION__, connections);
     return conn;
 }
 
@@ -1754,7 +1754,7 @@ static void connection_destroy(spice_connection *conn)
     free(conn);
 
     connections--;
-    SPICE_DEBUG("%s (%d)", __FUNCTION__, connections);
+    g_debug("%s (%d)", __FUNCTION__, connections);
     if (connections > 0) {
         return;
     }
@@ -1856,13 +1856,13 @@ int main(int argc, char *argv[])
     int mode = S_IRWXU;
     conf_file = g_build_filename(g_get_user_config_dir(), "spicy", NULL);
     if (g_mkdir_with_parents(conf_file, mode) == -1)
-        SPICE_DEBUG("failed to create config directory");
+        g_debug("failed to create config directory");
     g_free(conf_file);
 
     conf_file = g_build_filename(g_get_user_config_dir(), "spicy", "settings", NULL);
     if (!g_key_file_load_from_file(keyfile, conf_file,
                                    G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, &error)) {
-        SPICE_DEBUG("Couldn't load configuration: %s", error->message);
+        g_debug("Couldn't load configuration: %s", error->message);
         g_clear_error(&error);
     }
 
@@ -1922,7 +1922,7 @@ int main(int argc, char *argv[])
 
     if ((conf = g_key_file_to_data(keyfile, NULL, &error)) == NULL ||
         !g_file_set_contents(conf_file, conf, -1, &error)) {
-        SPICE_DEBUG("Couldn't save configuration: %s", error->message);
+        g_debug("Couldn't save configuration: %s", error->message);
         g_error_free(error);
         error = NULL;
     }
-- 
2.5.0



More information about the Spice-devel mailing list