X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=blobdiff_plain;f=src%2Fdebug.c;h=f44d9938487fe726711f289e3035da41ea2ff085;hp=aa66f988ac10a51bffeee585e5a2ded1bba880a6;hb=6eebdfd3f310e2823e45cda00b57b5e4f6839692;hpb=732210aa829e2c0cb9e74fe8fbab8f0dd4056454 diff --git a/src/debug.c b/src/debug.c index aa66f988..f44d9938 100644 --- a/src/debug.c +++ b/src/debug.c @@ -32,16 +32,6 @@ */ static gchar *regexp = NULL; -void set_regexp(gchar *cmd_regexp) -{ - regexp = g_strdup(cmd_regexp); -} - -gchar *get_regexp() -{ - return g_strdup(regexp); -} - static gboolean log_msg_cb(gpointer data) { gchar *buf = data; @@ -58,48 +48,72 @@ static gboolean log_normal_cb(gpointer data) return FALSE; } -void log_domain_printf(const gchar *domain, const gchar *format, ...) +void log_domain_print_message(const gchar *domain, gchar *buf) { - va_list ap; - gchar *buf; + gchar *buf_nl; regex_t regex; gint ret_comp, ret_exec; - gchar *filtered_buf; - va_start(ap, format); - buf = g_strdup_vprintf(format, ap); - va_end(ap); + buf_nl = g_strconcat(buf, "\n", NULL); - if (regexp && command_line && buf) + if (regexp && command_line) { - if (g_strcmp0(buf,"\n")) - { ret_comp = regcomp(®ex, regexp, 0); if (!ret_comp) { - ret_exec = regexec(®ex, buf, 0, NULL, 0); + ret_exec = regexec(®ex, buf_nl, 0, NULL, 0); - filtered_buf = g_strconcat(buf, "\n", NULL); if (!ret_exec) { - print_term(filtered_buf); + print_term(buf_nl); if (strcmp(domain, DOMAIN_INFO) == 0) - g_idle_add(log_normal_cb, filtered_buf); + g_idle_add(log_normal_cb, buf_nl); else - g_idle_add(log_msg_cb, filtered_buf); + g_idle_add(log_msg_cb, buf_nl); } regfree(®ex); } - } } else { - print_term(buf); + print_term(buf_nl); if (strcmp(domain, DOMAIN_INFO) == 0) - g_idle_add(log_normal_cb, buf); + g_idle_add(log_normal_cb, buf_nl); else - g_idle_add(log_msg_cb, buf); + g_idle_add(log_msg_cb, buf_nl); } + g_free(buf); +} + +void log_domain_print_debug(const gchar *domain, const gchar *file_name, + int line_number, const gchar *format, ...) +{ + va_list ap; + gchar *message; + gchar *location; + gchar *buf; + + va_start(ap, format); + message = g_strdup_vprintf(format, ap); + va_end(ap); + + location = g_strdup_printf("%s:%d:", file_name, line_number); + buf = g_strconcat(location, message, NULL); + log_domain_print_message(domain,buf); + g_free(location); + g_free(message); +} + +void log_domain_printf(const gchar *domain, const gchar *format, ...) +{ + va_list ap; + gchar *buf; + + va_start(ap, format); + buf = g_strdup_vprintf(format, ap); + va_end(ap); + + log_domain_print_message(domain, buf); } /* @@ -191,5 +205,15 @@ void init_exec_time(void) get_exec_time(); } +void set_regexp(gchar *cmd_regexp) +{ + regexp = g_strdup(cmd_regexp); +} + +gchar *get_regexp(void) +{ + return g_strdup(regexp); +} + #endif /* DEBUG */ /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */