Do not use printf() directly but use new wrapper function log_printf() instead.
authorLaurent Monin <geeqie@norz.org>
Fri, 16 May 2008 12:16:49 +0000 (12:16 +0000)
committerLaurent Monin <geeqie@norz.org>
Fri, 16 May 2008 12:16:49 +0000 (12:16 +0000)
26 files changed:
src/cache.c
src/cache_maint.c
src/collect-io.c
src/collect-table.c
src/collect.c
src/debug.c
src/debug.h
src/dupe.c
src/exif.c
src/exiv2.cc
src/filedata.c
src/filefilter.c
src/format_raw.c
src/image-load.c
src/main.c
src/pixbuf-renderer.c
src/pixbuf_util.c
src/print.c
src/remote.c
src/ui_bookmark.c
src/ui_fileops.c
src/ui_spinner.c
src/ui_tabcomp.c
src/utilops.c
src/view_dir_tree.c
src/window.c

index 2595480..ffbbc82 100644 (file)
@@ -158,7 +158,7 @@ gint cache_sim_data_save(CacheData *cd)
 
        if (!ssi)
                {
-               printf("Unable to save sim cache data: %s\n", cd->path);
+               log_printf("Unable to save sim cache data: %s\n", cd->path);
                return FALSE;
                }
 
@@ -606,7 +606,7 @@ gint cache_ensure_dir_exists(gchar *path, mode_t mode)
                                        DEBUG_1("creating sub dir:%s", path);
                                        if (!mkdir_utf8(path, mode))
                                                {
-                                               printf("create dir failed: %s\n", path);
+                                               log_printf("create dir failed: %s\n", path);
                                                return FALSE;
                                                }
                                        }
index 53154ea..a6aff79 100644 (file)
@@ -189,7 +189,7 @@ static gint cache_maintain_home_cb(gpointer data)
                                    (strlen(path_buf) > base_length && !isfile(path_buf + base_length)) )
                                        {
                                        if (dot) *dot = '.';
-                                       if (!unlink_file(path_buf)) printf("failed to delete:%s\n", path_buf);
+                                       if (!unlink_file(path_buf)) log_printf("failed to delete:%s\n", path_buf);
                                        }
                                else
                                        {
@@ -212,7 +212,7 @@ static gint cache_maintain_home_cb(gpointer data)
                        {
                        if (!still_have_a_file && !dlist && cm->list->next && !rmdir_utf8(fd->path))
                                {
-                               printf("Unable to delete dir: %s\n", fd->path);
+                               log_printf("Unable to delete dir: %s\n", fd->path);
                                }
                        }
                else
@@ -220,7 +220,7 @@ static gint cache_maintain_home_cb(gpointer data)
                        /* must re-check for an empty dir */
                        if (isempty(fd->path) && cm->list->next && !rmdir_utf8(fd->path))
                                {
-                               printf("Unable to delete dir: %s\n", fd->path);
+                               log_printf("Unable to delete dir: %s\n", fd->path);
                                }
                        }
 
@@ -377,7 +377,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
                                DEBUG_1("Deleting thumb dir: %s", fd->path);
                                if (!rmdir_utf8(fd->path))
                                        {
-                                       printf("Unable to delete dir: %s\n", fd->path);
+                                       log_printf("Unable to delete dir: %s\n", fd->path);
                                        }
                                }
                        else
@@ -401,7 +401,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
                            (strlen(path) > base_length && !isfile(path + base_length)) )
                                {
                                if (dot) *dot = '.';
-                               if (!unlink_file(path)) printf("failed to delete:%s\n", path);
+                               if (!unlink_file(path)) log_printf("failed to delete:%s\n", path);
                                }
                        else
                                {
@@ -533,7 +533,7 @@ void cache_maint_moved(FileData *fd)
                }
        else
                {
-               printf("Failed to create cache dir for move %s\n", base);
+               log_printf("Failed to create cache dir for move %s\n", base);
                }
        g_free(base);
 
index 5cc3c0c..f3ba47c 100644 (file)
@@ -101,7 +101,7 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, Colle
        g_free(pathl);
        if (!f)
                {
-               printf("Failed to open collection file: \"%s\"\n", path);
+               log_printf("Failed to open collection file: \"%s\"\n", path);
                return FALSE;
                }
 
@@ -167,7 +167,7 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, Colle
                                    fail > GQ_COLLECTION_FAIL_MIN &&
                                    fail * 100 / total > GQ_COLLECTION_FAIL_PERCENT)
                                        {
-                                       printf("%d invalid filenames in unofficial collection file, closing: %s\n", fail, path);
+                                       log_printf("%d invalid filenames in unofficial collection file, closing: %s\n", fail, path);
                                        success = FALSE;
                                        break;
                                        }
@@ -575,7 +575,7 @@ static void collect_manager_entry_add_action(CollectManagerEntry *entry, Collect
                if (orig_action)
                        {
                        /* target already exists */
-                       printf("collection manager failed to add another action for target %s in collection %s\n",
+                       log_printf("collection manager failed to add another action for target %s in collection %s\n",
                                action->newpath, entry->path);
                        return;
                        }
@@ -616,7 +616,7 @@ static void collect_manager_entry_add_action(CollectManagerEntry *entry, Collect
        if (orig_action)
                {
                /* another action for the same source, ignore */
-               printf("collection manager failed to add another action for source %s in collection %s\n",
+               log_printf("collection manager failed to add another action for source %s in collection %s\n",
                        action->oldpath, entry->path);
                return;
                }
@@ -763,7 +763,7 @@ static void collect_manager_process_actions(gint max)
                if (action->type != COLLECTION_MANAGER_UPDATE &&
                    action->oldpath && action->newpath)
                        {
-                       printf("collection manager failed to %s %s for collection %s\n",
+                       log_printf("collection manager failed to %s %s for collection %s\n",
                                (action->type == COLLECTION_MANAGER_ADD) ? "add" : "remove",
                                action->oldpath, action->newpath);
                        }
index 8884214..e7bfdea 100644 (file)
@@ -555,7 +555,7 @@ static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data)
 
        if (!collection_save(ct->cd, ct->cd->path))
                {
-               printf("failed saving to collection path: %s\n", ct->cd->path);
+               log_printf("failed saving to collection path: %s\n", ct->cd->path);
                }
 }
 
index 1ae962d..09e1d30 100644 (file)
@@ -98,7 +98,7 @@ gint collection_info_load_thumb(CollectInfo *ci)
 
        collection_info_free_thumb(ci);
 
-       printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
+       log_printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
        return FALSE;
 #if 0
        if (create_thumbnail(ci->fd->path, &ci->pixmap, &ci->mask) < 0) return FALSE;
@@ -905,7 +905,7 @@ static gint collection_window_keypress(GtkWidget *widget, GdkEventKey *event, gp
                                        }
                                else if (!collection_save(cw->cd, cw->cd->path))
                                        {
-                                       printf("failed saving to collection path: %s\n", cw->cd->path);
+                                       log_printf("failed saving to collection path: %s\n", cw->cd->path);
                                        }
                                break;
                        case 'A': case 'a':
index d20495d..dc4b1db 100644 (file)
 
 #include "main.h"
 
+
+/*
+ * Logging functions
+ */
+
+gint log_domain_printf(const char *domain, const gchar *format, ...)
+{
+       va_list ap;
+       gchar buf[4096];
+       gint ret;
+
+       va_start(ap, format);
+       ret = vsnprintf(buf, sizeof(buf), format, ap);
+       va_end(ap);
+
+       puts(buf);
+
+       return ret;
+}
+
+
+/*
+ * Debugging only functions
+ */
+
 #ifdef DEBUG
 
 static gint debug_level = DEBUG_LEVEL_MIN;
@@ -96,4 +121,4 @@ void init_exec_time(void)
        get_exec_time();
 }
 
-#endif
+#endif /* DEBUG */
index f413b21..404cceb 100644 (file)
 #ifndef DEBUG_H
 #define DEBUG_H
 
+#define DOMAIN_DEBUG "debug"
+#define DOMAIN_INFO  "info"
+
+gint log_domain_printf(const char *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+#define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
+
+
+
+
 #if 1 /* set to 0 to disable compilation of debugging code and related options */
 # ifndef DEBUG
 # define DEBUG 1
@@ -35,9 +44,9 @@ void init_exec_time(void);
                                gint debug_level = get_debug_level(); \
                                if (debug_level >= (n))         \
                                        {               \
-                                       if (debug_level != 1) printf("%s:%d: ", __FILE__, __LINE__); \
-                                       printf(__VA_ARGS__); \
-                                       putchar('\n'); \
+                                       if (debug_level != 1) log_domain_printf(DOMAIN_DEBUG, "%s:%d: ", __FILE__, __LINE__); \
+                                       log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \
+                                       log_domain_printf(DOMAIN_DEBUG, "\n"); \
                                        } \
                                } while (0)
 
index 4090db0..501d5af 100644 (file)
@@ -513,7 +513,7 @@ static void dupe_listview_add(DupeWindow *dw, DupeItem *parent, DupeItem *child)
                else
                        {
                        rank = 1;
-                       printf("NULL group in item!\n");
+                       log_printf("NULL group in item!\n");
                        }
                }
        else
@@ -928,7 +928,7 @@ static void dupe_match_print_group(DupeItem *di)
 {
        GList *work;
 
-       printf("+ %f %s\n", di->group_rank, di->fd->name);
+       log_printf("+ %f %s\n", di->group_rank, di->fd->name);
 
        work = di->group;
        while (work)
@@ -936,10 +936,10 @@ static void dupe_match_print_group(DupeItem *di)
                DupeMatch *dm = work->data;
                work = work->next;
 
-               printf("  %f %s\n", dm->rank, dm->di->fd->name);
+               log_printf("  %f %s\n", dm->rank, dm->di->fd->name);
                }
 
-       printf("\n");
+       log_printf("\n");
 }
 
 static void dupe_match_print_list(GList *list)
index 9411297..48b1425 100644 (file)
@@ -738,7 +738,7 @@ void exif_item_copy_data(ExifItem *item, void *src, guint len,
            ExifFormatList[src_format].size * ne > len)
                {
                gchar *tag = exif_item_get_tag_name(item);
-               printf("exif tag %s data size mismatch\n", tag);
+               log_printf("exif tag %s data size mismatch\n", tag);
                g_free(tag);
                return;
                }
@@ -840,7 +840,7 @@ static gint exif_parse_IFD_entry(ExifData *exif, unsigned char *tiff, guint offs
                {
                if (format >= EXIF_FORMAT_COUNT)
                        {
-                       printf("warning: exif tag 0x%4x has invalid format %d\n", tag, format);
+                       log_printf("warning: exif tag 0x%4x has invalid format %d\n", tag, format);
                        return 0;
                        }
                /* allow non recognized tags to be displayed */
@@ -863,13 +863,13 @@ static gint exif_parse_IFD_entry(ExifData *exif, unsigned char *tiff, guint offs
                        {
                        if (format < EXIF_FORMAT_COUNT)
                                {
-                               printf("warning: exif tag %s format mismatch, found %s exif spec requests %s\n",
+                               log_printf("warning: exif tag %s format mismatch, found %s exif spec requests %s\n",
                                        marker->key, ExifFormatList[format].short_name,
                                        ExifFormatList[marker->format].short_name);
                                }
                        else
                                {
-                               printf("warning: exif tag %s format mismatch, found unknown id %d exif spec requests %d (%s)\n",
+                               log_printf("warning: exif tag %s format mismatch, found unknown id %d exif spec requests %d (%s)\n",
                                        marker->key, format, marker->format,
                                        ExifFormatList[marker->format].short_name);
                                }
@@ -881,7 +881,7 @@ static gint exif_parse_IFD_entry(ExifData *exif, unsigned char *tiff, guint offs
         */
        if (marker->components > 0 && marker->components != count)
                {
-               printf("warning: exif tag %s has %d elements, exif spec requests %d\n",
+               log_printf("warning: exif tag %s has %d elements, exif spec requests %d\n",
                        marker->key, count, marker->components);
                }
 
@@ -891,7 +891,7 @@ static gint exif_parse_IFD_entry(ExifData *exif, unsigned char *tiff, guint offs
                data_offset = data_val;
                if (size < data_offset + data_length)
                        {
-                       printf("warning: exif tag %s data will overrun end of file, ignored.\n", marker->key);
+                       log_printf("warning: exif tag %s data will overrun end of file, ignored.\n", marker->key);
                        return -1;
                        }
                }
@@ -1521,7 +1521,7 @@ void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list)
 
 int exif_write(ExifData *exif)
 {
-       printf("Not compiled with EXIF write support");
+       log_printf("Not compiled with EXIF write support");
        return 0;
 }
 
index 18e0ff1..78a1f82 100644 (file)
@@ -710,7 +710,7 @@ RawFile::~RawFile(void)
 {
        if (map_data && munmap(map_data, map_len) == -1)
                {
-               printf("Failed to unmap file \n");
+               log_printf("Failed to unmap file \n");
                }
 }
 
@@ -782,7 +782,7 @@ extern "C" gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
                *image_offset = offset;
                if ((unsigned long) lseek(fd, *image_offset, SEEK_SET) != *image_offset)
                        {
-                       printf("Failed to seek to embedded image\n");
+                       log_printf("Failed to seek to embedded image\n");
 
                        *image_offset = 0;
                        if (*exif_offset) *exif_offset = 0;
index d867e74..3786c43 100644 (file)
@@ -117,7 +117,7 @@ const gchar *text_from_time(time_t t)
        ret = g_locale_to_utf8(buf, buflen, NULL, NULL, &error);
        if (error)
                {
-               printf("Error converting locale strftime to UTF-8: %s\n", error->message);
+               log_printf("Error converting locale strftime to UTF-8: %s\n", error->message);
                g_error_free(error);
                return "";
                }
index 67e3bfd..7cb113f 100644 (file)
@@ -307,7 +307,7 @@ void filter_rebuild(void)
                                }
                        else
                                {
-                               printf("WARNING: invalid file class %d\n", fe->file_class);
+                               log_printf("WARNING: invalid file class %d\n", fe->file_class);
                                }
                        }
                }
@@ -345,7 +345,7 @@ gint filter_file_class(const gchar *name, FileFormatClass file_class)
 
        if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES)
                {
-               printf("WARNING: invalid file class %d\n", file_class);
+               log_printf("WARNING: invalid file class %d\n", file_class);
                return FALSE;
                }
 
index 702797e..b2f73bf 100644 (file)
@@ -343,14 +343,14 @@ gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
 
        if (fstat(fd, &st) == -1)
                {
-               printf("Failed to stat file %d\n", fd);
+               log_printf("Failed to stat file %d\n", fd);
                return FALSE;
                }
        map_len = st.st_size;
        map_data = mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0);
        if (map_data == MAP_FAILED)
                {
-               printf("Failed to mmap file %d\n", fd);
+               log_printf("Failed to mmap file %d\n", fd);
                return FALSE;
                }
 
@@ -358,14 +358,14 @@ gint format_raw_img_exif_offsets_fd(int fd, const gchar *path,
 
        if (munmap(map_data, map_len) == -1)
                {
-               printf("Failed to unmap file %d\n", fd);
+               log_printf("Failed to unmap file %d\n", fd);
                }
 
        if (success && image_offset)
                {
                if (lseek(fd, *image_offset, SEEK_SET) != *image_offset)
                        {
-                       printf("Failed to seek to embedded image\n");
+                       log_printf("Failed to seek to embedded image\n");
 
                        *image_offset = 0;
                        if (*exif_offset) *exif_offset = 0;
@@ -462,7 +462,7 @@ static void format_debug_tiff_entry(unsigned char *data, const guint len, guint
                segment = offset + EXIF_TIFD_OFFSET_DATA;
                }
 
-       printf("%*stag:0x%04X (%05d), type:%2d %9s, len:%6d [%02X %02X %02X %02X] @ offset:%d\n",
+       log_printf("%*stag:0x%04X (%05d), type:%2d %9s, len:%6d [%02X %02X %02X %02X] @ offset:%d\n",
                level, "", tag, tag, type,
                (type < EXIF_FORMAT_COUNT) ? ExifFormatList[type].short_name : "???", count,
                data[segment], data[segment + 1], data[segment + 2], data[segment + 3], segment);
@@ -471,7 +471,7 @@ static void format_debug_tiff_entry(unsigned char *data, const guint len, guint
                {
                gint i;
 
-               printf("%*s~~~ found %s table\n", level, "", (tag == 0x14a) ? "subIFD" : "EXIF" );
+               log_printf("%*s~~~ found %s table\n", level, "", (tag == 0x14a) ? "subIFD" : "EXIF" );
 
                for (i = 0; i < count; i++)
                        {
@@ -483,17 +483,17 @@ static void format_debug_tiff_entry(unsigned char *data, const guint len, guint
                }
        else if (tag == 0x8773 && type == EXIF_FORMAT_UNDEFINED)
                {
-               printf("%*s~~~ found ICC color profile at offset %d, length %d\n", level, "", segment, seg_len);
+               log_printf("%*s~~~ found ICC color profile at offset %d, length %d\n", level, "", segment, seg_len);
                }
        else if (tag == 0x201 && (type == EXIF_FORMAT_LONG_UNSIGNED || type == EXIF_FORMAT_LONG))
                {
                guint subset = exif_byte_get_int32(data + segment, bo);
-               printf("%*s~~~ found jpeg data at offset %d\n", level, "", subset);
+               log_printf("%*s~~~ found jpeg data at offset %d\n", level, "", subset);
                }
        else if (tag == 0x202 && (type == EXIF_FORMAT_LONG_UNSIGNED || type == EXIF_FORMAT_LONG))
                {
                guint subset = exif_byte_get_int32(data + segment, bo);
-               printf("%*s~~~ found jpeg data length of %d\n", level, "", subset);
+               log_printf("%*s~~~ found jpeg data length of %d\n", level, "", subset);
                }
 }
 
@@ -511,14 +511,14 @@ static guint format_debug_tiff_table(unsigned char *data, const guint len, guint
        offset += 2;
        if (len < offset + count * EXIF_TIFD_SIZE + 4) return 0;
 
-       printf("%*s== tiff table #%d has %d entries ==\n", level, "", level, count);
+       log_printf("%*s== tiff table #%d has %d entries ==\n", level, "", level, count);
 
        for (i = 0; i < count; i++)
                {
                format_debug_tiff_entry(data, len, offset + i * EXIF_TIFD_SIZE, bo, level);
                }
 
-       printf("%*s----------- end of #%d ------------\n", level, "", level);
+       log_printf("%*s----------- end of #%d ------------\n", level, "", level);
 
        return exif_byte_get_int32(data + offset + count * EXIF_TIFD_SIZE, bo);
 }
@@ -546,7 +546,7 @@ gint format_debug_tiff_raw(unsigned char *data, const guint len,
                return FALSE;
                }
 
-       printf("*** debug parsing tiff\n");
+       log_printf("*** debug parsing tiff\n");
 
        offset = exif_byte_get_int32(data + 4, bo);
        level = 0;
@@ -556,7 +556,7 @@ gint format_debug_tiff_raw(unsigned char *data, const guint len,
                level++;
                }
 
-       printf("*** end\n");
+       log_printf("*** end\n");
 
        /* we are debugging, not trying to return any data */
        return FALSE;
index c30f2dd..3bb6764 100644 (file)
@@ -56,7 +56,7 @@ static void image_loader_area_updated_cb(GdkPixbufLoader *loader,
                        image_loader_sync_pixbuf(il);
                        if (!il->pixbuf)
                                {
-                               printf("critical: area_ready signal with NULL pixbuf (out of mem?)\n");
+                               log_printf("critical: area_ready signal with NULL pixbuf (out of mem?)\n");
                                }
                        }
                il->func_area_ready(il, x, y, w, h, il->data_area_ready);
index 3394555..232fbf3 100644 (file)
@@ -374,19 +374,19 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                        else if (strcmp(cmd_line, "-v") == 0 ||
                                 strcmp(cmd_line, "--version") == 0)
                                {
-                               printf("%s %s\n", GQ_APPNAME, VERSION);
+                               log_printf("%s %s\n", GQ_APPNAME, VERSION);
                                exit(0);
                                }
                        else if (strcmp(cmd_line, "--alternate") == 0)
                                {
                                /* enable faster experimental algorithm */
-                               printf("Alternate similarity algorithm enabled\n");
+                               log_printf("Alternate similarity algorithm enabled\n");
                                image_sim_alternate_set(TRUE);
                                }
                        else if (strcmp(cmd_line, "-h") == 0 ||
                                 strcmp(cmd_line, "--help") == 0)
                                {
-                               printf("%s %s\n", GQ_APPNAME, VERSION);
+                               log_printf("%s %s\n", GQ_APPNAME, VERSION);
                                printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC);
                                print_term(_("valid options are:\n"));
                                print_term(_("  +t, --with-tools           force show of tools\n"));
@@ -728,7 +728,7 @@ int main(int argc, char *argv[])
        srand(time(NULL));
 
 #if 1
-       printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
+       log_printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
 #endif
        parse_command_line_for_debug_option(argc, argv);
 
index a9c6e32..4fe38b2 100644 (file)
@@ -2102,7 +2102,7 @@ static void pr_tile_coords_map_orientation(PixbufRenderer *pr,
                        /* The other values are out of range */
                        break;
                }
-//     printf("tile coord y:%f, ih:%d, th:%f ry:%f\n", tile_y, image_h, tile_h, *res_x);
+//     log_printf("tile coord y:%f, ih:%d, th:%f ry:%f\n", tile_y, image_h, tile_h, *res_x);
 }
 
 static void pr_tile_region_map_orientation(PixbufRenderer *pr,
@@ -2165,7 +2165,7 @@ static void pr_tile_region_map_orientation(PixbufRenderer *pr,
                        /* The other values are out of range */
                        break;
                }
-//     printf("inside y:%d, th:%d, ah:%d ry:%d\n", area_y, tile_h, area_h, *res_x);
+//     log_printf("inside y:%d, th:%d, ah:%d ry:%d\n", area_y, tile_h, area_h, *res_x);
 }
 
 static void pr_coords_map_orientation_reverse(PixbufRenderer *pr,
@@ -2986,7 +2986,7 @@ static void pr_redraw(PixbufRenderer *pr, gint new_data)
 static void pr_update_signal(PixbufRenderer *pr)
 {
 #if 0
-       printf("FIXME: send updated signal\n");
+       log_printf("FIXME: send updated signal\n");
 #endif
        DEBUG_1("%s pixbuf renderer updated - started drawing %p", get_exec_time(), pr);
        pr->debug_updated = TRUE;
index fba7c31..55e289d 100644 (file)
@@ -37,7 +37,7 @@ gboolean pixbuf_to_file_as_png(GdkPixbuf *pixbuf, const char *filename)
 
        if (error)
                {
-               printf("Error saving png file: %s\n", error->message);
+               log_printf("Error saving png file: %s\n", error->message);
                g_error_free(error);
                }
 
@@ -61,7 +61,7 @@ gboolean pixbuf_to_file_as_jpg(GdkPixbuf *pixbuf, const gchar *filename, gint qu
        if (quality == -1) quality = 75;
        if (quality < 1 || quality > 100)
                {
-               printf("Jpeg not saved, invalid quality %d\n", quality);
+               log_printf("Jpeg not saved, invalid quality %d\n", quality);
                return FALSE;
                }
 
@@ -71,7 +71,7 @@ gboolean pixbuf_to_file_as_jpg(GdkPixbuf *pixbuf, const gchar *filename, gint qu
 
        if (error)
                {
-               printf("Error saving jpeg to %s\n%s\n", filename, error->message);
+               log_printf("Error saving jpeg to %s\n%s\n", filename, error->message);
                g_error_free(error);
                }
 
@@ -125,7 +125,7 @@ GdkPixbuf *pixbuf_inline(const gchar *key)
                i++;
                }
 
-       printf("warning: inline pixbuf key \"%s\" not found.\n", key);
+       log_printf("warning: inline pixbuf key \"%s\" not found.\n", key);
 
        return NULL;
 }
index 102f0f4..37f69ba 100644 (file)
@@ -967,7 +967,7 @@ static PipeError *pipe_handler_new(void)
 
        if (pipe_handler_data)
                {
-               printf("warning SIGPIPE handler already in use\n");
+               log_printf("warning SIGPIPE handler already in use\n");
                return NULL;
                }
 
@@ -990,7 +990,7 @@ static PipeError *pipe_handler_new(void)
 static void pipe_handler_free(PipeError *pe)
 {
        if (!pe) return;
-       if (pe != pipe_handler_data) printf("warning SIGPIPE handler not closing same data\n");
+       if (pe != pipe_handler_data) log_printf("warning SIGPIPE handler not closing same data\n");
 
        /* restore the original signal handler */
        sigaction(SIGPIPE, &pe->old_action, NULL);
@@ -1622,11 +1622,11 @@ static gdouble convert_pango_dpi(gdouble points)
                                {
                                if (dpi == 0.0)
                                        {
-                                       printf("pango dpi unknown, assuming %.0f\n", fallback_dpi);
+                                       log_printf("pango dpi unknown, assuming %.0f\n", fallback_dpi);
                                        }
                                else
                                        {
-                                       printf("pango dpi reported as %.0f ignored, assuming %.0f\n", dpi, fallback_dpi);
+                                       log_printf("pango dpi reported as %.0f ignored, assuming %.0f\n", dpi, fallback_dpi);
                                        }
                                warned = TRUE;
                                }
index db44460..a4f1ce9 100644 (file)
@@ -92,7 +92,7 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
 
                if (error)
                        {
-                       printf("error reading socket: %s\n", error->message);
+                       log_printf("error reading socket: %s\n", error->message);
                        g_error_free(error);
                        }
 
@@ -131,7 +131,7 @@ static void remote_server_client_add(RemoteConnection *rc, int fd)
 
        if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS)
                {
-               printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS);
+               log_printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS);
                close(fd);
                return;
                }
@@ -172,7 +172,7 @@ static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition
        fd = accept(rc->fd, NULL, &alen);
        if (fd == -1)
                {
-               printf("error accepting socket: %s\n", strerror(errno));
+               log_printf("error accepting socket: %s\n", strerror(errno));
                return TRUE;
                }
 
@@ -206,7 +206,7 @@ static RemoteConnection *remote_server_open(const gchar *path)
 
        if (remote_server_exists(path))
                {
-               printf("Address already in use: %s\n", path);
+               log_printf("Address already in use: %s\n", path);
                return NULL;
                }
 
@@ -219,7 +219,7 @@ static RemoteConnection *remote_server_open(const gchar *path)
        if (bind(fd, &addr, sizeof(addr)) == -1 ||
            listen(fd, REMOTE_SERVER_BACKLOG) == -1)
                {
-               printf("error subscribing to socket: %s\n", strerror(errno));
+               log_printf("error subscribing to socket: %s\n", strerror(errno));
                close(fd);
                return NULL;
                }
@@ -314,11 +314,11 @@ static gint remote_client_send(RemoteConnection *rc, const gchar *text)
                {
                if (sigpipe_occured)
                        {
-                       printf("SIGPIPE writing to socket: %s\n", rc->path);
+                       log_printf("SIGPIPE writing to socket: %s\n", rc->path);
                        }
                else
                        {
-                       printf("error writing to socket: %s\n", strerror(errno));
+                       log_printf("error writing to socket: %s\n", strerror(errno));
                        }
                ret = FALSE;;
                }
@@ -493,7 +493,7 @@ static void gr_file_load(const gchar *text, gpointer data)
                }
        else
                {
-               printf("remote sent filename that does not exist:\"%s\"\n", filename);
+               log_printf("remote sent filename that does not exist:\"%s\"\n", filename);
                }
 
        g_free(filename);
@@ -644,7 +644,7 @@ static void remote_cb(RemoteConnection *rc, const gchar *text, gpointer data)
                }
        else
                {
-               printf("unknown remote command:%s\n", text);
+               log_printf("unknown remote command:%s\n", text);
                }
 }
 
index 0586896..dff3723 100644 (file)
@@ -452,7 +452,7 @@ static BookButtonData *bookmark_from_string(const gchar *text)
 
        if (path_ptr && icon_ptr && icon_ptr < path_ptr)
                {
-               printf("warning, bookmark icon must be after path\n");
+               log_printf("warning, bookmark icon must be after path\n");
                return NULL;
                }
 
@@ -1228,7 +1228,7 @@ void history_combo_append_history(GtkWidget *widget, const gchar *text)
        hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
        if (!hc)
                {
-               printf("widget is not a history combo\n");
+               log_printf("widget is not a history combo\n");
                return;
                }
 
index ba3f0e3..d49bc4f 100644 (file)
@@ -131,7 +131,7 @@ gchar *path_to_utf8(const gchar *path)
        utf8 = g_filename_to_utf8(path, -1, NULL, NULL, &error);
        if (error)
                {
-               printf("Unable to convert filename to UTF-8:\n%s\n%s\n", path, error->message);
+               log_printf("Unable to convert filename to UTF-8:\n%s\n%s\n", path, error->message);
                g_error_free(error);
                encoding_dialog(path);
                }
@@ -154,7 +154,7 @@ gchar *path_from_utf8(const gchar *utf8)
        path = g_filename_from_utf8(utf8, -1, NULL, NULL, &error);
        if (error)
                {
-               printf("Unable to convert filename to locale from UTF-8:\n%s\n%s\n", utf8, error->message);
+               log_printf("Unable to convert filename to locale from UTF-8:\n%s\n%s\n", utf8, error->message);
                g_error_free(error);
                }
        if (!path)
index b66aefb..1f4fe1a 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <gtk/gtk.h>
 
+#include "main.h"
 #include "ui_spinner.h"
 
 #include "ui_icons.h"
@@ -199,7 +200,7 @@ void spinner_step(GtkWidget *spinner, gint reset)
        sp = g_object_get_data(G_OBJECT(spinner), "spinner");
        if (sp->timer_id != -1)
                {
-               printf("spinner warning: attempt to step with timer set\n");
+               log_printf("spinner warning: attempt to step with timer set\n");
                return;
                }
 
index 0b904d1..9ac50f4 100644 (file)
@@ -778,7 +778,7 @@ void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gcha
        TabCompData *td;
        if (!entry)
                {
-               printf("Tab completion error: entry != NULL\n");
+               log_printf("Tab completion error: entry != NULL\n");
                return;
                }
 
index 774dbab..addbda6 100644 (file)
@@ -3028,7 +3028,7 @@ FileData *file_util_delete_dir_empty_path(FileData *fd, gint real_content, gint
        level++;
        if (level > UTILITY_DELETE_MAX_DEPTH)
                {
-               printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
+               log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
                return file_data_ref(fd);
                }
 
index d08db8f..b913871 100644 (file)
@@ -585,7 +585,7 @@ FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint
                        if (work == list)
                                {
                                /* should not happen */
-                               printf("vdtree warning, root node not found\n");
+                               log_printf("vdtree warning, root node not found\n");
                                parts_list_free(list);
                                vdtree_busy_pop(vd);
                                return NULL;
@@ -597,7 +597,7 @@ FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint
                            !vdtree_populate_path_by_iter(vd, &parent_iter, force, path) ||
                            (nd = vdtree_find_iter_by_name(vd, &parent_iter, pd->name, &iter)) == NULL)
                                {
-                               printf("vdtree warning, aborted at %s\n", parent_pd->name);
+                               log_printf("vdtree warning, aborted at %s\n", parent_pd->name);
                                parts_list_free(list);
                                vdtree_busy_pop(vd);
                                return NULL;
@@ -726,7 +726,7 @@ void vdtree_refresh(ViewDir *vd)
 
 const gchar *vdtree_row_get_path(ViewDir *vd, gint row)
 {
-       printf("FIXME: no get row path\n");
+       log_printf("FIXME: no get row path\n");
        return NULL;
 }
 
index f4dbd9c..4515bd7 100644 (file)
@@ -185,7 +185,7 @@ static void help_browser_run(void)
 
        if (!result)
                {
-               printf("Unable to detect an installed browser.\n");
+               log_printf("Unable to detect an installed browser.\n");
                return;
                }