Revise DEBUG_0() usage
authorColin Clark <colin.clark@cclark.uk>
Sun, 17 Sep 2017 09:33:08 +0000 (10:33 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sun, 17 Sep 2017 09:33:08 +0000 (10:33 +0100)
Replace all DEBUG_0() calls with log_printf() or another debug level.
This will stop the user seeing irrelevant debug output
when the debug level is set to the default of 0.

CODING
src/filedata.c
src/fullscreen.c
src/layout_util.c
src/pixbuf-renderer.c
src/preferences.c
src/renderer-clutter.c
src/ui_misc.c

diff --git a/CODING b/CODING
index ea28fa4..ca55a23 100644 (file)
--- a/CODING
+++ b/CODING
@@ -1,3 +1,16 @@
+Log Window:
+
+DEBUG_0()
+Use DEBUG_0() only for temporary debugging i.e. not in code in the repository.
+The user will then not see irrelevant debug output when the default
+debug level = 0 is used.
+
+log_printf()
+If the first word of the message is "error" or "warning" (case insensitive)
+the message will be color-coded appropriately.
+
+--------------------------------------------------------------------------------
+
 GPL header, in every file, like this:
 
 /** \file
index 3bbbbfb..3862277 100644 (file)
@@ -578,9 +578,9 @@ FileData *file_data_ref(FileData *fd)
        if (fd == NULL) return NULL;
        if (fd->magick != FD_MAGICK)
 #ifdef DEBUG_FILEDATA
-               DEBUG_0("fd magick mismatch @ %s:%d  fd=%p", file, line, fd);
+               log_printf("Error: fd magick mismatch @ %s:%d  fd=%p", file, line, fd);
 #else
-               DEBUG_0("fd magick mismatch fd=%p", fd);
+               log_printf("Error: fd magick mismatch fd=%p", fd);
 #endif
        g_assert(fd->magick == FD_MAGICK);
        fd->ref++;
@@ -681,9 +681,9 @@ void file_data_unref(FileData *fd)
        if (fd == NULL) return;
        if (fd->magick != FD_MAGICK)
 #ifdef DEBUG_FILEDATA
-               DEBUG_0("fd magick mismatch @ %s:%d  fd=%p", file, line, fd);
+               log_printf("Error: fd magick mismatch @ %s:%d  fd=%p", file, line, fd);
 #else
-               DEBUG_0("fd magick mismatch fd=%p", fd);
+               log_printf("Error: fd magick mismatch fd=%p", fd);
 #endif
        g_assert(fd->magick == FD_MAGICK);
 
@@ -713,7 +713,7 @@ void file_data_unref(FileData *fd)
 void file_data_lock(FileData *fd)
 {
        if (fd == NULL) return;
-       if (fd->magick != FD_MAGICK) DEBUG_0("fd magick mismatch fd=%p", fd);
+       if (fd->magick != FD_MAGICK) log_printf("Error: fd magick mismatch fd=%p", fd);
 
        g_assert(fd->magick == FD_MAGICK);
        fd->locked = TRUE;
@@ -731,7 +731,7 @@ void file_data_lock(FileData *fd)
 void file_data_unlock(FileData *fd)
 {
        if (fd == NULL) return;
-       if (fd->magick != FD_MAGICK) DEBUG_0("fd magick mismatch fd=%p", fd);
+       if (fd->magick != FD_MAGICK) log_printf("Error: fd magick mismatch fd=%p", fd);
 
        g_assert(fd->magick == FD_MAGICK);
        fd->locked = FALSE;
index 4ae884c..048fe3f 100644 (file)
@@ -300,12 +300,12 @@ FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd,
 
        if (fs->same_region)
                {
-               DEBUG_0("Original window is not visible, enabling std. fullscreen mode");
+               DEBUG_2("Original window is not visible, enabling std. fullscreen mode");
                image_move_from_image(fs->imd, fs->normal_imd);
                }
        else
                {
-               DEBUG_0("Original window is still visible, enabling presentation fullscreen mode");
+               DEBUG_2("Original window is still visible, enabling presentation fullscreen mode");
                image_copy_from_image(fs->imd, fs->normal_imd);
                }
 
index 9c320bb..e9f107b 100644 (file)
@@ -1180,7 +1180,7 @@ static void layout_menu_kbd_map_cb(GtkAction *action, gpointer data)
        fd = g_file_open_tmp("geeqie_keymap_XXXXXX.svg", &tmp_file, &error);
        if (error)
                {
-               DEBUG_0("Keyboard Map - cannot create file:%s\n",error->message);
+               log_printf("Error: Keyboard Map - cannot create file:%s\n",error->message);
                g_error_free(error);
                }
        else
@@ -1223,7 +1223,7 @@ static void layout_menu_kbd_map_cb(GtkAction *action, gpointer data)
 
                                converted_line = g_strconcat(pre_key[0], ">", key_name, "<", post_key[1], "\n", NULL);
                                g_io_channel_write_chars(channel, converted_line, -1, NULL, &error);
-                               if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
+                               if (error) {log_printf("Warning: Keyboard Map:%s\n",error->message); g_error_free(error);}
 
                                g_free(converted_line);
                                g_strfreev(pre_key);
@@ -1232,15 +1232,15 @@ static void layout_menu_kbd_map_cb(GtkAction *action, gpointer data)
                        else
                                {
                                g_io_channel_write_chars(channel, keymap_template[keymap_index], -1, NULL, &error);
-                               if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
+                               if (error) {log_printf("Warning: Keyboard Map:%s\n",error->message); g_error_free(error);}
                                g_io_channel_write_chars(channel, "\n", -1, NULL, &error);
-                               if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
+                               if (error) {log_printf("Warning: Keyboard Map:%s\n",error->message); g_error_free(error);}
                                }
                        keymap_index++;
                        }
 
                g_io_channel_flush(channel, &error);
-               if (error) {DEBUG_0("Keyboard Map:%s\n",error->message); g_error_free(error);}
+               if (error) {log_printf("Warning: Keyboard Map:%s\n",error->message); g_error_free(error);}
                g_io_channel_unref(channel);
 
                index=0;
index 07de0e7..65f4f14 100644 (file)
@@ -406,7 +406,7 @@ static RendererFuncs *pr_backend_renderer_new(PixbufRenderer *pr)
 #ifdef HAVE_CLUTTER
                return renderer_clutter_new(pr);
 #else
-               DEBUG_0("Geeqie is built without clutter renderer support");
+               log_printf("Warning: Geeqie is built without clutter renderer support");
 #endif
                }
        return renderer_tiles_new(pr);
index d8f86ce..dada370 100644 (file)
@@ -1424,7 +1424,6 @@ static void cache_standard_cb(GtkWidget *widget, gpointer data)
                {
                c_options->thumbnails.spec_standard =FALSE;
                }
-               DEBUG_0("standard %d",c_options->thumbnails.spec_standard);
 }
 
 static void cache_geeqie_cb(GtkWidget *widget, gpointer data)
@@ -1438,7 +1437,6 @@ static void cache_geeqie_cb(GtkWidget *widget, gpointer data)
                {
                c_options->thumbnails.spec_standard =FALSE;
                }
-               DEBUG_0("geeqie %d",c_options->thumbnails.spec_standard);
 }
 
 static void cache_local_cb(GtkWidget *widget, gpointer data)
index 1f56710..e0fd959 100644 (file)
@@ -172,7 +172,7 @@ static void rc_set_shader(CoglHandle material, const RendererClutterShaderInfo *
        );
        cogl_shader_compile(shader);
        gchar *err = cogl_shader_get_info_log(shader);
-       DEBUG_0("%s\n",err);
+       DEBUG_3("%s\n",err);
        g_free(err);
 
        program = cogl_create_program ();
@@ -215,7 +215,7 @@ static void rc_prepare_post_process_lut(RendererClutter *rc)
        CoglHandle material;
        CoglHandle tex3d;
 
-       DEBUG_0("%s clut start", get_exec_time());
+       DEBUG_3("%s clut start", get_exec_time());
 
        for (r = 0; r < CLUT_SIZE; r++)
                {
@@ -241,7 +241,7 @@ static void rc_prepare_post_process_lut(RendererClutter *rc)
                }
        g_object_unref(tmp_pixbuf);
 
-       DEBUG_0("%s clut upload start", get_exec_time());
+       DEBUG_3("%s clut upload start", get_exec_time());
 #if COGL_VERSION_CHECK(1,18,2)
        {
        CoglContext *ctx = clutter_backend_get_cogl_context(clutter_get_default_backend ());
@@ -280,7 +280,7 @@ static void rc_prepare_post_process_lut(RendererClutter *rc)
        material = clutter_texture_get_cogl_material(CLUTTER_TEXTURE(rc->texture));
        cogl_material_set_layer(material, 1, tex3d);
        cogl_handle_unref(tex3d);
-       DEBUG_0("%s clut end", get_exec_time());
+       DEBUG_3("%s clut end", get_exec_time());
        rc->clut_updated = TRUE;
 }
 
@@ -296,8 +296,8 @@ static void rc_sync_actor(RendererClutter *rc)
 
        clutter_actor_set_anchor_point(CLUTTER_ACTOR(rc->texture), 0, 0);
 
-       DEBUG_0("scale %d %d", rc->pr->width, rc->pr->height);
-       DEBUG_0("pos   %d %d", rc->pr->x_offset, rc->pr->y_offset);
+       DEBUG_3("scale %d %d", rc->pr->width, rc->pr->height);
+       DEBUG_3("pos   %d %d", rc->pr->x_offset, rc->pr->y_offset);
 
        clutter_actor_set_scale(CLUTTER_ACTOR(rc->texture),
                                (gfloat)pr->width / pr->image_width,
@@ -400,13 +400,13 @@ static void rc_schedule_texture_upload(RendererClutter *rc)
                {
                /* delay clutter redraw until the texture has some data
                   set priority between gtk redraw and clutter redraw */
-               DEBUG_0("%s tex upload high prio", get_exec_time());
+               DEBUG_3("%s tex upload high prio", get_exec_time());
                rc->idle_update = g_idle_add_full(CLUTTER_PRIORITY_REDRAW - 10, rc_area_changed_cb, rc, NULL);
                }
        else
                {
                /* higher prio than histogram */
-               DEBUG_0("%s tex upload low prio", get_exec_time());
+               DEBUG_3("%s tex upload low prio", get_exec_time());
 
                rc->idle_update = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE - 5, rc_area_changed_cb, rc, NULL);
                }
@@ -424,7 +424,7 @@ static gboolean rc_area_changed_cb(gpointer data)
        if (h > par->h) h = par->h;
 
 
-       DEBUG_0("%s upload start", get_exec_time());
+       DEBUG_3("%s upload start", get_exec_time());
        if (pr->pixbuf)
                {
                CoglHandle texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(rc->texture));
@@ -442,7 +442,7 @@ static gboolean rc_area_changed_cb(gpointer data)
                                        gdk_pixbuf_get_rowstride(pr->pixbuf),
                                        gdk_pixbuf_get_pixels(pr->pixbuf));
                }
-       DEBUG_0("%s upload end", get_exec_time());
+       DEBUG_3("%s upload end", get_exec_time());
        rc_area_clip_add(rc, par->x, par->y, par->w, h);
 
 
@@ -519,19 +519,19 @@ static void rc_update_pixbuf(void *renderer, gboolean lazy)
        RendererClutter *rc = (RendererClutter *)renderer;
        PixbufRenderer *pr = rc->pr;
 
-       DEBUG_0("rc_update_pixbuf");
+       DEBUG_3("rc_update_pixbuf");
 
        rc_remove_pending_updates(rc);
 
        rc->last_pixbuf_change = g_get_monotonic_time();
-       DEBUG_0("%s change time reset", get_exec_time());
+       DEBUG_3("%s change time reset", get_exec_time());
 
        if (pr->pixbuf)
                {
                gint width = gdk_pixbuf_get_width(pr->pixbuf);
                gint height = gdk_pixbuf_get_height(pr->pixbuf);
 
-               DEBUG_0("pixbuf size %d x %d (%d)", width, height, gdk_pixbuf_get_has_alpha(pr->pixbuf) ? 32 : 24);
+               DEBUG_3("pixbuf size %d x %d (%d)", width, height, gdk_pixbuf_get_has_alpha(pr->pixbuf) ? 32 : 24);
 
                gint prev_width, prev_height;
 
@@ -573,7 +573,7 @@ static void rc_update_zoom(void *renderer, gboolean lazy)
 {
        RendererClutter *rc = (RendererClutter *)renderer;
 
-       DEBUG_0("rc_update_zoom");
+       DEBUG_3("rc_update_zoom");
        rc_sync_actor(rc);
 }
 
@@ -771,7 +771,7 @@ static void rc_update_viewport(void *renderer)
                        rc->stereo_off_y = rc->pr->stereo_fixed_y_left;
                        }
                }
-       DEBUG_0("rc_update_viewport  scale %d %d", rc->pr->width, rc->pr->height);
+       DEBUG_3("rc_update_viewport  scale %d %d", rc->pr->width, rc->pr->height);
 
        clutter_stage_set_color(CLUTTER_STAGE(rc->stage), &stage_color);
 
@@ -795,7 +795,7 @@ static void rc_update_viewport(void *renderer)
 
 static void rc_scroll(void *renderer, gint x_off, gint y_off)
 {
-       DEBUG_0("rc_scroll");
+       DEBUG_3("rc_scroll");
        RendererClutter *rc = (RendererClutter *)renderer;
 
        rc_sync_actor(rc);
@@ -883,7 +883,7 @@ RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
                if (!GTK_CLUTTER_IS_EMBED(rc->widget))
                        {
                        g_free(rc);
-                       DEBUG_0("pixbuf renderer has a child of other type than gtk_clutter_embed");
+                       DEBUG_3("pixbuf renderer has a child of other type than gtk_clutter_embed");
                        return NULL;
                        }
                }
index b7725bf..a5e905d 100644 (file)
@@ -1065,7 +1065,7 @@ GtkWidget *date_selection_new(void)
                                        ds->spin_y = pref_spin_new(ds->box, NULL, NULL, 1900, 9999, 1, 0, 1900, NULL, NULL);
                                        break;
                                default:
-                                       DEBUG_0("Date locale %s is unknown", date_format);
+                                       log_printf("Warning: Date locale %s is unknown", date_format);
                                        break;
                                }
                        }