[gnome-shell] Implement Telepathy Debug interface (#652816)



commit b22c5eb1671cd6a0155d7cf2d97651ec6c315cd0
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jun 20 15:01:54 2011 +0200

    Implement Telepathy Debug interface (#652816)
    
    This enable debugging using empathy-debugger.

 src/main.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 0e77187..aafef06 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,6 +19,8 @@
 #include <meta/main.h>
 #include <meta/meta-plugin.h>
 #include <meta/prefs.h>
+#include <telepathy-glib/debug.h>
+#include <telepathy-glib/debug-sender.h>
 
 #include "shell-a11y.h"
 #include "shell-global.h"
@@ -428,6 +430,25 @@ muted_log_handler (const char     *log_domain,
   /* Intentionally empty to discard message */
 }
 
+static void
+default_log_handler (const char     *log_domain,
+                     GLogLevelFlags  log_level,
+                     const char     *message,
+                     gpointer        data)
+{
+  TpDebugSender *sender = data;
+  GTimeVal now;
+
+  g_get_current_time (&now);
+
+  tp_debug_sender_add_message (sender, &now, log_domain, log_level, message);
+
+  /* Filter out telepathy-glib logs, we don't want to flood Shell's output
+   * with those. */
+  if (!g_str_has_prefix (log_domain, "tp-glib"))
+    g_log_default_handler (log_domain, log_level, message, data);
+}
+
 static gboolean
 print_version (const gchar    *option_name,
                const gchar    *value,
@@ -454,6 +475,7 @@ main (int argc, char **argv)
   GOptionContext *ctx;
   GError *error = NULL;
   int ecode;
+  TpDebugSender *sender;
 
   g_type_init ();
 
@@ -505,6 +527,14 @@ main (int argc, char **argv)
   g_log_set_handler ("Bluetooth", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE,
                      muted_log_handler, NULL);
 
+  /* Turn on telepathy-glib debugging but filter it out in
+   * default_log_handler. This handler also exposes all the logs over D-Bus
+   * using TpDebugSender. */
+  tp_debug_set_flags ("all");
+
+  sender = tp_debug_sender_dup ();
+  g_log_set_default_handler (default_log_handler, sender);
+
   /* Initialize the global object */
   shell_global_get ();
 
@@ -516,5 +546,7 @@ main (int argc, char **argv)
       g_object_unref (shell_global_get ());
     }
 
+  g_object_unref (sender);
+
   return ecode;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]