Commit 086fa280 authored by Olivier Crête's avatar Olivier Crête

debug: Add nice_debug_set_from_string() API to set extra debug cats

This allows changing the debug cats more or less at runtime.
parent 837ed596
......@@ -83,28 +83,32 @@ stun_handler (const char *format, va_list ap)
g_logv ("libnice-stun", G_LOG_LEVEL_DEBUG, format, ap);
}
void nice_debug_init (void)
void
nice_debug_set_from_string (const gchar *extra_string)
{
static gboolean debug_initialized = FALSE;
const gchar *flags_string;
const gchar *gflags_string;
guint flags = 0;
if (!debug_initialized) {
debug_initialized = TRUE;
flags_string = g_getenv ("NICE_DEBUG");
gflags_string = g_getenv ("G_MESSAGES_DEBUG");
if (flags_string)
flags = g_parse_debug_string (flags_string, keys, 4);
if (gflags_string)
flags |= g_parse_debug_string (gflags_string, gkeys, 4);
if (gflags_string && strstr (gflags_string, "libnice-pseudotcp-verbose"))
flags |= NICE_DEBUG_PSEUDOTCP_VERBOSE;
if (gflags_string && strstr (gflags_string, "libnice-verbose")) {
if (gflags_string && strstr (gflags_string, "libnice-verbose"))
flags |= NICE_DEBUG_NICE_VERBOSE;
if (extra_string)
flags |= g_parse_debug_string (extra_string, gkeys, 4);
if (extra_string && strstr (extra_string, "libnice-pseudotcp-verbose"))
flags |= NICE_DEBUG_PSEUDOTCP_VERBOSE;
if (extra_string && strstr (extra_string, "libnice-verbose"))
flags |= NICE_DEBUG_NICE_VERBOSE;
}
stun_set_debug_handler (stun_handler);
debug_enabled = !!(flags & NICE_DEBUG_NICE);
......@@ -123,6 +127,15 @@ void nice_debug_init (void)
pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);
else if (flags & NICE_DEBUG_PSEUDOTCP)
pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_NORMAL);
}
void nice_debug_init (void)
{
static gboolean debug_initialized = FALSE;
if (!debug_initialized) {
debug_initialized = TRUE;
nice_debug_set_from_string (NULL);
}
}
......
......@@ -99,6 +99,19 @@ void nice_debug_enable (gboolean with_stun);
*/
void nice_debug_disable (gboolean with_stun);
/**
* nice_debug_set_from_string:
* @extra_string: String in the style of G_MESSAGES_DEBUG
*
* This parses the same kind of string that could be passed to the
* standard G_MESSAGES_DEBUG environment variable. It uses the categorie defined
* in the doc for the nice_debug_enable() function.
*
* Since: 0.1.15
*/
void nice_debug_set_from_string (const gchar *extra_string);
G_END_DECLS
#endif /* __LIBNICE_DEBUG_H__ */
......
......@@ -126,6 +126,7 @@ nice_address_ip_version
<TITLE>Debug messages</TITLE>
nice_debug_enable
nice_debug_disable
nice_debug_set_from_string
</SECTION>
<SECTION>
......
......@@ -64,6 +64,7 @@ nice_candidate_new
nice_component_state_to_string
nice_debug_disable
nice_debug_enable
nice_debug_set_from_string
nice_interfaces_get_ip_for_interface
nice_interfaces_get_local_interfaces
nice_interfaces_get_local_ips
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment