Improve debug output
authorColin Clark <colin.clark@cclark.uk>
Tue, 8 Aug 2017 21:10:21 +0000 (22:10 +0100)
committerColin Clark <colin.clark@cclark.uk>
Tue, 8 Aug 2017 21:10:21 +0000 (22:10 +0100)
Use __func__ compiler identifier

src/debug.c
src/debug.h

index f44d993..851bb79 100644 (file)
@@ -85,7 +85,7 @@ void log_domain_print_message(const gchar *domain, gchar *buf)
        g_free(buf);
 }
 
-void log_domain_print_debug(const gchar *domain, const gchar *file_name,
+void log_domain_print_debug(const gchar *domain, const gchar *file_name, const gchar *function_name,
                                                                        int line_number, const gchar *format, ...)
 {
        va_list ap;
@@ -97,7 +97,7 @@ void log_domain_print_debug(const gchar *domain, const gchar *file_name,
        message = g_strdup_vprintf(format, ap);
        va_end(ap);
 
-       location = g_strdup_printf("%s:%d:", file_name, line_number);
+       location = g_strdup_printf("%s:%s:%d:", file_name, function_name, line_number);
        buf = g_strconcat(location, message, NULL);
        log_domain_print_message(domain,buf);
        g_free(location);
index d8a34b9..50b99a5 100644 (file)
@@ -27,8 +27,8 @@
 #define DOMAIN_INFO  "info"
 
 void log_domain_printf(const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
-void log_domain_print_debug(const gchar *domain, const gchar *file_name,
-                                                       int line_number, const gchar *format, ...) G_GNUC_PRINTF(4, 5);
+void log_domain_print_debug(const gchar *domain, const gchar *file_name, const gchar *function_name,
+                                                       int line_number, const gchar *format, ...) G_GNUC_PRINTF(5, 6);
 #define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
 
 #ifdef DEBUG
@@ -51,9 +51,9 @@ void init_exec_time(void);
                                if (debug_level >= (n))         \
                                        {               \
                                        if (debug_level != 1) \
-                                       { \
-                                               log_domain_print_debug(DOMAIN_DEBUG, __FILE__, __LINE__, __VA_ARGS__); \
-                                       } \
+                                               { \
+                                               log_domain_printf(DOMAIN_DEBUG, "%s:%s:%d: ", __FILE__, __func__, __LINE__); \
+                                               } \
                                        else \
                                                { \
                                                log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \