diff options
author | Sjoerd Simons <sjoerd@luon.net> | 2006-10-23 17:21:35 +0000 |
---|---|---|
committer | Sjoerd Simons <sjoerd@luon.net> | 2006-10-23 17:21:35 +0000 |
commit | 976aa5bfc213732d960614150cea12c06988c339 (patch) | |
tree | 53975f76d6d911815644ab3e997c5a451392f855 /src/debug.c | |
parent | 36e7ba52d4397763aca609c368bc6f2472b644a1 (diff) | |
download | telepathy-salut-976aa5bfc213732d960614150cea12c06988c339.tar.gz |
[project @ 94458aec8a5f2139cc075945f7336e4307c8d96e]
First commit!
20061023172135-93b9a-ce433f8baae54b25e36a061c2863bd4304ac3f8a.gz
Diffstat (limited to 'src/debug.c')
-rw-r--r-- | src/debug.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c new file mode 100644 index 00000000..a880b068 --- /dev/null +++ b/src/debug.c @@ -0,0 +1,64 @@ + +#include <stdarg.h> + +#include <glib.h> + +#include "debug.h" + +#ifdef ENABLE_DEBUG + +static DebugFlags flags = 0; + +GDebugKey keys[] = { + { "presence", DEBUG_PRESENCE }, + { "groups", DEBUG_GROUPS }, + { "contacts", DEBUG_CONTACTS }, + { "disco", DEBUG_DISCO }, + { "properties", DEBUG_PROPERTIES }, + { "roomlist", DEBUG_ROOMLIST }, + { "media-channel", DEBUG_MEDIA }, + { "muc", DEBUG_MUC }, + { "connection", DEBUG_CONNECTION }, + { "persist", DEBUG_PERSIST }, + { "all", ~0 }, + { 0, }, +}; + +void debug_set_flags_from_env () +{ + guint nkeys; + const gchar *flags_string; + + for (nkeys = 0; keys[nkeys].value; nkeys++); + + flags_string = g_getenv ("SALUT_DEBUG"); + + if (flags_string) + debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); +} + +void debug_set_flags (DebugFlags new_flags) +{ + flags |= new_flags; +} + +gboolean debug_flag_is_set (DebugFlags flag) +{ + return flag & flags; +} + +void debug (DebugFlags flag, + const gchar *format, + ...) +{ + if (flag & flags) + { + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); + va_end (args); + } +} + +#endif /* ENABLE_DEBUG */ + |