summaryrefslogtreecommitdiff
path: root/agent/debug.c
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2010-12-09 22:24:28 -0500
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2010-12-09 22:24:28 -0500
commit47e6a9b948c2ffa2a426f6229886f38d214cab3b (patch)
tree34bd02f3a20d229296fc99e51d7ba99354a82a76 /agent/debug.c
parent69888aa8da79dabeda57e0df4f804bae899d80f0 (diff)
downloadlibnice-47e6a9b948c2ffa2a426f6229886f38d214cab3b.tar.gz
Allow nice_debug_enable and nice_debug_disable to be called before the first NiceAgent is instanciated
Diffstat (limited to 'agent/debug.c')
-rw-r--r--agent/debug.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/agent/debug.c b/agent/debug.c
index 802d444..a7f1340 100644
--- a/agent/debug.c
+++ b/agent/debug.c
@@ -61,40 +61,46 @@ static const GDebugKey keys[] = {
void nice_debug_init ()
{
+ static gboolean debug_initialized = FALSE;
const gchar *flags_string;
guint flags;
- flags_string = g_getenv ("NICE_DEBUG");
+ if (!debug_initialized) {
+ debug_initialized = TRUE;
- nice_debug_disable (TRUE);
+ flags_string = g_getenv ("NICE_DEBUG");
- if (flags_string != NULL) {
- flags = g_parse_debug_string (flags_string, keys, 4);
+ nice_debug_disable (TRUE);
- if (flags & NICE_DEBUG_NICE)
- nice_debug_enable (FALSE);
- if (flags & NICE_DEBUG_STUN)
- stun_debug_enable ();
+ if (flags_string != NULL) {
+ flags = g_parse_debug_string (flags_string, keys, 4);
- /* Set verbose before normal so that if we use 'all', then only
- normal debug is enabled, we'd need to set pseudotcp-verbose without the
- pseudotcp flag in order to actually enable verbose pseudotcp */
- if (flags & NICE_DEBUG_PSEUDOTCP_VERBOSE)
- pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);
- if (flags & NICE_DEBUG_PSEUDOTCP)
- pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_NORMAL);
+ if (flags & NICE_DEBUG_NICE)
+ nice_debug_enable (FALSE);
+ if (flags & NICE_DEBUG_STUN)
+ stun_debug_enable ();
+ /* Set verbose before normal so that if we use 'all', then only
+ normal debug is enabled, we'd need to set pseudotcp-verbose without the
+ pseudotcp flag in order to actually enable verbose pseudotcp */
+ if (flags & NICE_DEBUG_PSEUDOTCP_VERBOSE)
+ pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);
+ if (flags & NICE_DEBUG_PSEUDOTCP)
+ pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_NORMAL);
+ }
}
}
void nice_debug_enable (gboolean with_stun)
{
+ nice_debug_init ();
debug_enabled = 1;
if (with_stun)
stun_debug_enable ();
}
void nice_debug_disable (gboolean with_stun)
{
+ nice_debug_init ();
debug_enabled = 0;
if (with_stun)
stun_debug_disable ();