[Telepathy-commits] [telepathy-haze/master] Add "haze" and "purple" debug flags to enable debug output from each.

Will Thompson will.thompson at collabora.co.uk
Wed Aug 13 09:38:03 PDT 2008


This is not very fine-grained, but at least means you can run haze
without any debugging output at all.
---
 src/debug.c |   66 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/src/debug.c b/src/debug.c
index 861a503..000dd56 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -26,6 +26,45 @@
 #include <libpurple/debug.h>
 #include <telepathy-glib/debug.h>
 
+
+typedef enum
+{
+    HAZE_DEBUG_HAZE   = 1 << 0,
+    HAZE_DEBUG_PURPLE = 1 << 1,
+} HazeDebugFlags;
+
+
+static GDebugKey keys[] =
+{
+    { "haze",   HAZE_DEBUG_HAZE },
+    { "purple", HAZE_DEBUG_PURPLE },
+};
+
+
+static HazeDebugFlags flags = 0;
+
+
+void
+haze_debug_set_flags_from_env ()
+{
+    const gchar *env = g_getenv ("HAZE_DEBUG");
+
+    if (env)
+    {
+       flags |= g_parse_debug_string (env, keys, 2);
+    }
+
+    tp_debug_set_flags (env);
+
+    if (g_getenv ("HAZE_PERSIST"))
+        tp_debug_set_persistent (TRUE);
+
+#ifdef HAVE_TP_DEBUG_DIVERT_MESSAGES
+    tp_debug_divert_messages (g_getenv ("HAZE_LOGFILE"));
+#endif
+}
+
+
 static char *debug_level_names[] =
 {
     "all",
@@ -68,6 +107,9 @@ static gboolean
 haze_debug_is_enabled (PurpleDebugLevel level,
                        const char *category)
 {
+    if (!(flags & HAZE_DEBUG_PURPLE))
+        return FALSE;
+
     if (level == PURPLE_DEBUG_MISC)
         return FALSE;
     /* oscar and yahoo, among others, supply a NULL category for some of their
@@ -120,23 +162,13 @@ void
 haze_debug (const gchar *format,
             ...)
 {
-    va_list args;
-    va_start (args, format);
-
-    g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
-
-    va_end (args);
-}
-
-void
-haze_debug_set_flags_from_env ()
-{
-    tp_debug_set_flags (g_getenv ("HAZE_DEBUG"));
+    if (flags & HAZE_DEBUG_HAZE)
+    {
+        va_list args;
+        va_start (args, format);
 
-    if (g_getenv ("HAZE_PERSIST"))
-        tp_debug_set_persistent (TRUE);
+        g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
 
-#ifdef HAVE_TP_DEBUG_DIVERT_MESSAGES
-    tp_debug_divert_messages (g_getenv ("HAZE_LOGFILE"));
-#endif
+        va_end (args);
+    }
 }
-- 
1.5.6.3



More information about the Telepathy-commits mailing list