Remove commented out code.
[geeqie.git] / src / debug.c
index c3858a2..a7f2417 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Geeqie
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Authors: Vladimir Nadvornik, Laurent Monin
  *
 #include "logwindow.h"
 #include "ui_fileops.h"
 
+#include <glib/gprintf.h>
+
 /*
  * Logging functions
  */
 
-gint log_domain_printf(const char *domain, const gchar *format, ...)
+static gboolean log_msg_cb(gpointer data)
+{
+       gchar *buf = data;
+       log_window_append(buf, LOG_MSG);
+       g_free(buf);
+       return FALSE;
+}
+
+static gboolean log_normal_cb(gpointer data)
+{
+       gchar *buf = data;
+       log_window_append(buf, LOG_NORMAL);
+       g_free(buf);
+       return FALSE;
+}
+
+void log_domain_printf(const gchar *domain, const gchar *format, ...)
 {
        va_list ap;
-       gchar buf[4096];
-       gint ret;
+       gchar *buf;
 
        va_start(ap, format);
-       ret = vsnprintf(buf, sizeof(buf), format, ap);
+       buf = g_strdup_vprintf(format, ap);
        va_end(ap);
 
        print_term(buf);
        if (strcmp(domain, DOMAIN_INFO) == 0)
-               log_window_append(buf, LOG_NORMAL);
+               g_idle_add(log_normal_cb, buf);
        else
-               log_window_append(buf, LOG_MSG);
+               g_idle_add(log_msg_cb, buf);
 
-       return ret;
 }
 
-
 /*
  * Debugging only functions
  */
@@ -118,7 +133,7 @@ const gchar *get_exec_time(void)
        previous = tv;
        started = 1;
 
-       g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (int)tv.tv_sec, (int)tv.tv_usec, (int)delta.tv_sec, (int)delta.tv_usec);
+       g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (gint)tv.tv_sec, (gint)tv.tv_usec, (gint)delta.tv_sec, (gint)delta.tv_usec);
 
        return timestr;
 }
@@ -129,3 +144,4 @@ void init_exec_time(void)
 }
 
 #endif /* DEBUG */
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */