[telepathy-gabble/master] Split logging to debugger into another function.

Jonny Lamb jonny.lamb at collabora.co.uk
Wed Jun 3 06:10:53 PDT 2009


Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 src/debug.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/debug.c b/src/debug.c
index 20aa664..45f7509 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -83,9 +83,10 @@ debug_flag_to_key (GabbleDebugFlags flag)
   return NULL;
 }
 
-void gabble_debug (GabbleDebugFlags flag,
-                   const gchar *format,
-                   ...)
+static void
+log_to_debugger (GabbleDebugFlags flag,
+		 const gchar *format,
+		 va_list args)
 {
   GabbleDebugger *dbg = gabble_debugger_get_singleton ();
   gdouble seconds;
@@ -93,19 +94,34 @@ void gabble_debug (GabbleDebugFlags flag,
   va_list args;
   GTimeVal now;
 
-  va_start (args, format);
-
   g_get_current_time (&now);
   seconds = now.tv_sec + now.tv_usec / 1e6;
+
   domain = g_strdup_printf ("%s/%s", G_LOG_DOMAIN, debug_flag_to_key (flag));
+
+  va_start (args, format);
   message = g_strdup_vprintf (format, args);
+
   gabble_debugger_add_message (dbg, seconds, domain, G_LOG_LEVEL_DEBUG, message);
 
+  g_free (message);
+  g_free (domain);
+  va_end (args);
+}
+
+void gabble_debug (GabbleDebugFlags flag,
+                   const gchar *format,
+                   ...)
+{
+  va_list args;
+
+  va_start (args, format);
+
+  log_to_debugger (flag, format, args);
+
   if (flag & flags)
     g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
 
-  g_free (domain);
-  g_free (message);
   va_end (args);
 }
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list