Implement Telepathy Debug interface (#652816)
This enable debugging using empathy-debugger.
This commit is contained in:
parent
6d5e414863
commit
b22c5eb167
32
src/main.c
32
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user