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 { "node", JSON_DEBUG_NODE },
13 };
14 #endif /* JSON_ENABLE_DEBUG */
15
16 JsonDebugFlags
json_get_debug_flags(void)17 json_get_debug_flags (void)
18 {
19 #ifdef JSON_ENABLE_DEBUG
20 static gboolean json_debug_flags_set;
21 const gchar *env_str;
22
23 if (G_LIKELY (json_debug_flags_set))
24 return json_debug_flags;
25
26 env_str = g_getenv ("JSON_DEBUG");
27 if (env_str != NULL && *env_str != '\0')
28 {
29 json_debug_flags |= g_parse_debug_string (env_str,
30 json_debug_keys,
31 G_N_ELEMENTS (json_debug_keys));
32 }
33
34 json_debug_flags_set = TRUE;
35 #endif /* JSON_ENABLE_DEBUG */
36
37 return json_debug_flags;
38 }
39