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;
}
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;
}
}
(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
{
{
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
/* 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);
}
}
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
(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
{
}
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);
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;
}
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;
}
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;
}
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;
}
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);
}
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);
}
}
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;
}
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':
#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;
get_exec_time();
}
-#endif
+#endif /* DEBUG */
#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
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)
else
{
rank = 1;
- printf("NULL group in item!\n");
+ log_printf("NULL group in item!\n");
}
}
else
{
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)
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)
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;
}
{
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 */
{
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);
}
*/
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);
}
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;
}
}
int exif_write(ExifData *exif)
{
- printf("Not compiled with EXIF write support");
+ log_printf("Not compiled with EXIF write support");
return 0;
}
{
if (map_data && munmap(map_data, map_len) == -1)
{
- printf("Failed to unmap file \n");
+ log_printf("Failed to unmap file \n");
}
}
*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;
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 "";
}
}
else
{
- printf("WARNING: invalid file class %d\n", fe->file_class);
+ log_printf("WARNING: invalid file class %d\n", fe->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;
}
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;
}
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;
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);
{
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++)
{
}
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);
}
}
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);
}
return FALSE;
}
- printf("*** debug parsing tiff\n");
+ log_printf("*** debug parsing tiff\n");
offset = exif_byte_get_int32(data + 4, bo);
level = 0;
level++;
}
- printf("*** end\n");
+ log_printf("*** end\n");
/* we are debugging, not trying to return any data */
return FALSE;
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);
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"));
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);
/* 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,
/* 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,
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;
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);
}
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;
}
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);
}
i++;
}
- printf("warning: inline pixbuf key \"%s\" not found.\n", key);
+ log_printf("warning: inline pixbuf key \"%s\" not found.\n", key);
return NULL;
}
if (pipe_handler_data)
{
- printf("warning SIGPIPE handler already in use\n");
+ log_printf("warning SIGPIPE handler already in use\n");
return NULL;
}
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);
{
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;
}
if (error)
{
- printf("error reading socket: %s\n", error->message);
+ log_printf("error reading socket: %s\n", error->message);
g_error_free(error);
}
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;
}
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;
}
if (remote_server_exists(path))
{
- printf("Address already in use: %s\n", path);
+ log_printf("Address already in use: %s\n", path);
return NULL;
}
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;
}
{
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;;
}
}
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);
}
else
{
- printf("unknown remote command:%s\n", text);
+ log_printf("unknown remote command:%s\n", 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;
}
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;
}
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);
}
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)
#include <gtk/gtk.h>
+#include "main.h"
#include "ui_spinner.h"
#include "ui_icons.h"
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;
}
TabCompData *td;
if (!entry)
{
- printf("Tab completion error: entry != NULL\n");
+ log_printf("Tab completion error: entry != NULL\n");
return;
}
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);
}
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;
!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;
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;
}
if (!result)
{
- printf("Unable to detect an installed browser.\n");
+ log_printf("Unable to detect an installed browser.\n");
return;
}