tizen 2.4 release
[external/libjson-glib.git] / json-glib / json-debug.c
1 #include "config.h"
2
3 #include "json-debug.h"
4
5 static unsigned int json_debug_flags = 0;
6
7 #ifdef JSON_ENABLE_DEBUG
8 static const GDebugKey json_debug_keys[] = {
9   { "parser", JSON_DEBUG_PARSER },
10   { "gobject", JSON_DEBUG_GOBJECT },
11   { "path", JSON_DEBUG_PATH }
12 };
13 #endif /* JSON_ENABLE_DEBUG */
14
15 JsonDebugFlags
16 json_get_debug_flags (void)
17 {
18 #ifdef JSON_ENABLE_DEBUG
19   static gboolean json_debug_flags_set;
20   const gchar *env_str;
21
22   if (G_LIKELY (json_debug_flags_set))
23     return json_debug_flags;
24
25   env_str = g_getenv ("JSON_DEBUG");
26   if (env_str != NULL && *env_str != '\0')
27     {
28       json_debug_flags |= g_parse_debug_string (env_str,
29                                                 json_debug_keys,
30                                                 G_N_ELEMENTS (json_debug_keys));
31     }
32
33   json_debug_flags_set = TRUE;
34 #endif /* JSON_ENABLE_DEBUG */
35
36   return json_debug_flags;
37 }