diff src/thumb_standard.c @ 495:c7a2471e5c4e

Introduce macros to display debug messages. if (debug) printf(...) is now replaced by variadic macros: DEBUG_1() And for higher debugging levels: DEBUG_2() DEBUG_3() DEBUG_4()
author zas_
date Wed, 23 Apr 2008 20:47:19 +0000
parents 48c8e49b571c
children fc9c8a3e1a8b
line wrap: on
line diff
--- a/src/thumb_standard.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/thumb_standard.c	Wed Apr 23 20:47:19 2008 +0000
@@ -235,11 +235,7 @@
 			if (mtime_str && strtol(mtime_str, NULL, 10) == tl->source_mtime)
 				{
 				result = TRUE;
-				if (debug)
-					{
-					printf("thumb fail valid: %s\n", tl->source_path);
-					printf("           thumb: %s\n", fail_path);
-					}
+				DEBUG_1("thumb fail valid: %s\n           thumb: %s\n", tl->source_path, fail_path);
 				}
 
 			g_object_unref(G_OBJECT(pixbuf));
@@ -336,11 +332,7 @@
 		}
 	g_free(base_path);
 
-	if (debug)
-		{
-		printf("thumb saving: %s\n", tl->source_path);
-		printf("       saved: %s\n", tl->thumb_path);
-		}
+	DEBUG_1("thumb saving: %s\n       saved: %s\n", tl->source_path, tl->thumb_path);
 
 	/* save thumb, using a temp file then renaming into place */
 	tmp_path = unique_filename(tl->thumb_path, ".tmp", "_", 2);
@@ -459,7 +451,7 @@
 
 			tl->cache_hit = FALSE;
 
-			if (debug) printf("thumb copied: %s\n", tl->source_path);
+			DEBUG_1("thumb copied: %s\n", tl->source_path);
 
 			thumb_loader_std_save(tl, pixbuf);
 			}
@@ -508,7 +500,7 @@
 		{
 		if (!tl->thumb_path_local && remove_broken)
 			{
-			if (debug) printf("thumb broken, unlinking: %s\n", tl->thumb_path);
+			DEBUG_1("thumb broken, unlinking: %s\n", tl->thumb_path);
 			unlink_file(tl->thumb_path);
 			}
 
@@ -540,16 +532,12 @@
 	ThumbLoaderStd *tl = data;
 	GdkPixbuf *pixbuf;
 
-	if (debug)
-		{
-		printf("thumb image done: %s\n", tl->source_path);
-		printf("            from: %s\n", tl->il->path);
-		}
+	DEBUG_1("thumb image done: %s\n            from: %s\n", tl->source_path, tl->il->path);
 
 	pixbuf = image_loader_get_pixbuf(tl->il);
 	if (!pixbuf)
 		{
-		if (debug) printf("...but no pixbuf\n");
+		DEBUG_1("...but no pixbuf\n");
 		thumb_loader_std_error_cb(il, data);
 		return;
 		}
@@ -579,12 +567,8 @@
 		thumb_loader_std_done_cb(il, data);
 		return;
 		}
-
-	if (debug)
-		{
-		printf("thumb image error: %s\n", tl->source_path);
-		printf("             from: %s\n", tl->il->fd->path);
-		}
+	
+	DEBUG_1("thumb image error: %s\n             from: %s\n", tl->source_path, tl->il->fd->path);
 
 	if (thumb_loader_std_next_source(tl, TRUE)) return;
 
@@ -821,7 +805,7 @@
 				{
 				struct stat st;
 
-				if (debug) printf("thumb uri foreign, doing day check: %s\n", uri);
+				DEBUG_1("thumb uri foreign, doing day check: %s\n", uri);
 
 				if (stat_utf8(tv->path, &st))
 					{
@@ -902,7 +886,7 @@
 					  local, subfolder);
 	if (isfile(thumb_path))
 		{
-		if (debug) printf("thumb removing: %s\n", thumb_path);
+		DEBUG_1("thumb removing: %s\n", thumb_path);
 		unlink_file(thumb_path);
 		}
 	g_free(thumb_path);
@@ -991,12 +975,12 @@
 			tm->tl->thumb_path = NULL;
 			tm->tl->thumb_path_local = FALSE;
 
-			if (debug) printf("thumb move attempting save:\n");
+			DEBUG_1("thumb move attempting save:\n");
 
 			thumb_loader_std_save(tm->tl, pixbuf);
 			}
 
-		if (debug) printf("thumb move unlink: %s\n", tm->thumb_path);
+		DEBUG_1("thumb move unlink: %s\n", tm->thumb_path);
 		unlink_file(tm->thumb_path);
 		}