diff src/collect-io.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 dead6fb690c5
children fc9c8a3e1a8b
line wrap: on
line diff
--- a/src/collect-io.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/collect-io.c	Wed Apr 23 20:47:19 2008 +0000
@@ -92,7 +92,7 @@
 
 	if (!path) path = cd->path;
 
-	if (debug) printf("collection load: append=%d flush=%d only_geometry=%d path=%s\n",
+	DEBUG_1("collection load: append=%d flush=%d only_geometry=%d path=%s\n",
 			  append, flush, only_geometry, path);
 
 	/* load it */
@@ -156,7 +156,7 @@
 				changed |= collect_manager_process_action(entry, &buf);
 
 			valid = (buf[0] == '/' && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
-			if (debug && !valid) printf("collection invalid file: %s\n", buf);
+			if (!valid) DEBUG_1("collection invalid file: %s\n", buf);
 			g_free(buf);
 
 			total++;
@@ -175,7 +175,7 @@
 			}
 		}
 
-	if (debug) printf("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d\n",
+	DEBUG_1("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d\n",
 			  total, fail, has_official_header, has_gqview_header, has_geometry_header);
 
 	fclose(f);
@@ -292,7 +292,7 @@
 	if (!thumb_loader_start(cd->thumb_loader, ci->fd->path))
 		{
 		/* error, handle it, do next */
-		if (debug) printf("error loading thumb for %s\n", ci->fd->path);
+		DEBUG_1("error loading thumb for %s\n", ci->fd->path);
 		collection_load_thumb_do(cd);
 		collection_load_thumb_step(cd);
 		}
@@ -721,11 +721,8 @@
 
 static void collect_manager_process_actions(gint max)
 {
-	if (debug && collection_manager_action_list)
-		{
-		printf("collection manager processing actions\n");
-		}
-
+	if (collection_manager_action_list) DEBUG_1("collection manager processing actions\n");
+	
 	while (collection_manager_action_list != NULL && max > 0)
 		{
 		CollectManagerAction *action;
@@ -823,13 +820,13 @@
 
 	if (collect_manager_process_entry_list()) return TRUE;
 
-	if (debug) printf("collection manager is up to date\n");
+	DEBUG_1("collection manager is up to date\n");
 	return FALSE;
 }
 
 static gint collect_manager_timer_cb(gpointer data)
 {
-	if (debug) printf("collection manager timer expired\n");
+	DEBUG_1("collection manager timer expired\n");
 
 	g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, NULL, NULL);
 
@@ -851,7 +848,7 @@
 		{
 		collection_manager_timer_id = g_timeout_add(COLLECT_MANAGER_FLUSH_DELAY,
 							    collect_manager_timer_cb, NULL);
-		if (debug) printf("collection manager timer started\n");
+		DEBUG_1("collection manager timer started\n");
 		}
 }
 
@@ -928,6 +925,6 @@
 {
 	collect_manager_timer_push(TRUE);
 
-	if (debug) printf("collection manager flushing\n");
+	DEBUG_1("collection manager flushing\n");
 	while (collect_manager_process_cb(NULL));
 }