From 9e1dfb2b84bf50dd07ba9f2fa97f0e6d3ca40e17 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Tue, 16 Feb 2010 17:34:46 -0800 Subject: [PATCH] Use telepathy debug interface https://bugs.freedesktop.org/show_bug.cgi?id=26597 --- src/mcd-debug.c | 28 ++++++++++++++++++++++++++++ src/mcd-debug.h | 8 ++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/mcd-debug.c b/src/mcd-debug.c index 2242613..c7b4db5 100644 --- a/src/mcd-debug.c +++ b/src/mcd-debug.c @@ -40,6 +40,7 @@ #include #include +#include #include @@ -186,3 +187,30 @@ mcd_debug_set_level (gint level) } } +void +mcd_debug (const gchar *format, + ...) +{ + TpDebugSender *dbg; + GTimeVal now; + gchar *message; + va_list args; + + va_start (args, format); + message = g_strdup_vprintf (format, args); + va_end (args); + + if (_mcd_debug_get_level () > 0) + g_debug ("%s", message); + + dbg = tp_debug_sender_dup (); + + g_get_current_time (&now); + + tp_debug_sender_add_message (dbg, &now, G_LOG_DOMAIN, + G_LOG_LEVEL_DEBUG, message); + + g_object_unref (dbg); + + g_free (message); +} diff --git a/src/mcd-debug.h b/src/mcd-debug.h index 99bfcdb..bf2cc47 100644 --- a/src/mcd-debug.h +++ b/src/mcd-debug.h @@ -37,10 +37,8 @@ G_BEGIN_DECLS #ifdef ENABLE_DEBUG #define DEBUGGING (_mcd_debug_get_level () > 0) -#define DEBUG(format, ...) G_STMT_START { \ - if (_mcd_debug_get_level () > 0) \ - g_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__); \ -} G_STMT_END +#define DEBUG(format, ...) \ + mcd_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__) #else /* !defined ENABLE_DEBUG */ @@ -66,6 +64,8 @@ void mcd_debug_unref (gpointer obj, const gchar *filename, gint linenum) void mcd_debug_print_tree (gpointer obj); +void mcd_debug (const gchar *format, ...); + G_END_DECLS #endif /* __MCD_DEBUG_H__ */ -- 1.7.0