changeset 2604:425b69f7ff5f

Revise DEBUG_0() usage 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.
author Colin Clark <colin.clark@cclark.uk>
date Sun, 17 Sep 2017 10:33:08 +0100
parents 0f9a732f4205
children 71e7f2a9b52c
files 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
diffstat 8 files changed, 45 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/CODING	Sun Sep 17 09:32:01 2017 +0100
+++ b/CODING	Sun Sep 17 10:33:08 2017 +0100
@@ -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
--- a/src/filedata.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/filedata.c	Sun Sep 17 10:33:08 2017 +0100
@@ -578,9 +578,9 @@
 	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 @@
 	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_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_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;
--- a/src/fullscreen.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/fullscreen.c	Sun Sep 17 10:33:08 2017 +0100
@@ -300,12 +300,12 @@
 
 	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);
 		}
 
--- a/src/layout_util.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/layout_util.c	Sun Sep 17 10:33:08 2017 +0100
@@ -1180,7 +1180,7 @@
 	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 @@
 
 				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 @@
 			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;
--- a/src/pixbuf-renderer.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/pixbuf-renderer.c	Sun Sep 17 10:33:08 2017 +0100
@@ -406,7 +406,7 @@
 #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);
--- a/src/preferences.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/preferences.c	Sun Sep 17 10:33:08 2017 +0100
@@ -1424,7 +1424,6 @@
 		{
 		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 @@
 		{
 		c_options->thumbnails.spec_standard =FALSE;
 		}
-		DEBUG_0("geeqie %d",c_options->thumbnails.spec_standard);
 }
 
 static void cache_local_cb(GtkWidget *widget, gpointer data)
--- a/src/renderer-clutter.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/renderer-clutter.c	Sun Sep 17 10:33:08 2017 +0100
@@ -172,7 +172,7 @@
 	);
 	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 @@
 	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 @@
 		}
 	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 @@
 	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 @@
 
 	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 @@
 		{
 		/* 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 @@
 	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 @@
 					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 @@
 	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 @@
 {
 	RendererClutter *rc = (RendererClutter *)renderer;
 
-	DEBUG_0("rc_update_zoom");
+	DEBUG_3("rc_update_zoom");
 	rc_sync_actor(rc);
 }
 
@@ -771,7 +771,7 @@
 			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_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 @@
 		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;
 			}
 		}
--- a/src/ui_misc.c	Sun Sep 17 09:32:01 2017 +0100
+++ b/src/ui_misc.c	Sun Sep 17 10:33:08 2017 +0100
@@ -1065,7 +1065,7 @@
 					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;
 				}
 			}