1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
|
2 /* |
|
3 * Copyright (C) 2003 Imendio AB |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or |
|
6 * modify it under the terms of the GNU Lesser General Public License as |
|
7 * published by the Free Software Foundation; either version 2 of the |
|
8 * License, or (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 * Lesser General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Lesser General Public |
|
16 * License along with this program; if not, write to the |
|
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 * Boston, MA 02111-1307, USA. |
|
19 */ |
|
20 |
|
21 #include "lm-debug.h" |
|
22 |
|
23 |
|
24 //#ifdef EMULATOR |
|
25 #ifndef LM_NO_DEBUG |
|
26 |
|
27 |
|
28 #ifdef EMULATOR |
|
29 #include "libloudmouth_wsd_solution.h" |
|
30 |
|
31 GET_GLOBAL_VAR_FROM_TLS(debug_flags,lm_debug,LmLogLevelFlags) |
|
32 #define debug_flags (*GET_WSD_VAR_NAME(debug_flags,lm_debug,g)()) |
|
33 |
|
34 GET_GLOBAL_VAR_FROM_TLS(initialized,lm_debug,gboolean) |
|
35 #define initialized (*GET_WSD_VAR_NAME(initialized,lm_debug,g)()) |
|
36 |
|
37 GET_GLOBAL_VAR_FROM_TLS(log_handler_id,lm_debug,guint) |
|
38 #define log_handler_id (*GET_WSD_VAR_NAME(log_handler_id,lm_debug,g)()) |
|
39 |
|
40 #else //EMULATOR |
|
41 |
|
42 |
|
43 static LmLogLevelFlags debug_flags = 0; |
|
44 static gboolean initialized = FALSE; |
|
45 static guint log_handler_id = 0; |
|
46 #endif//EMULATOR |
|
47 |
|
48 |
|
49 static const GDebugKey debug_keys[] = { |
|
50 {"VERBOSE", LM_LOG_LEVEL_VERBOSE}, |
|
51 {"NET", LM_LOG_LEVEL_NET}, |
|
52 {"PARSER", LM_LOG_LEVEL_PARSER}, |
|
53 {"SSL", LM_LOG_LEVEL_SSL}, |
|
54 {"SASL", LM_LOG_LEVEL_SASL}, |
|
55 {"ALL", LM_LOG_LEVEL_ALL} |
|
56 }; |
|
57 |
|
58 #define NUM_DEBUG_KEYS (sizeof (debug_keys) / sizeof (GDebugKey)) |
|
59 |
|
60 static void |
|
61 debug_log_handler (const gchar *log_domain, |
|
62 GLogLevelFlags log_level, |
|
63 const gchar *message, |
|
64 gpointer user_data) |
|
65 { |
|
66 |
|
67 |
|
68 /*if (debug_flags & log_level) { |
|
69 if (log_level & LM_LOG_LEVEL_VERBOSE) { |
|
70 g_print ("*** "); |
|
71 } |
|
72 else if (log_level & LM_LOG_LEVEL_PARSER) { |
|
73 g_print ("LM-PARSER: "); |
|
74 } |
|
75 else if (log_level & LM_LOG_LEVEL_SASL) { |
|
76 g_print ("LM-SASL: "); |
|
77 } |
|
78 else if (log_level & LM_LOG_LEVEL_SSL) { |
|
79 g_print ("LM-SSL: "); |
|
80 } |
|
81 |
|
82 g_print ("%s", message);*/ |
|
83 UNUSED_FORMAL_PARAM(log_domain); |
|
84 UNUSED_FORMAL_PARAM(log_level); |
|
85 UNUSED_FORMAL_PARAM(user_data); |
|
86 lm_verbose (message); |
|
87 //} |
|
88 } |
|
89 |
|
90 /** |
|
91 * lm_debug_init |
|
92 * |
|
93 * Initialized the debug system. |
|
94 **/ |
|
95 void |
|
96 lm_debug_init (void) |
|
97 { |
|
98 /*const gchar *env_lm_debug; |
|
99 |
|
100 if (initialized) { |
|
101 return; |
|
102 } |
|
103 |
|
104 env_lm_debug = g_getenv ("LM_DEBUG"); |
|
105 if (env_lm_debug) { |
|
106 debug_flags = g_parse_debug_string (env_lm_debug, debug_keys, |
|
107 NUM_DEBUG_KEYS); |
|
108 } |
|
109 |
|
110 log_handler_id = g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL, |
|
111 debug_log_handler, NULL); |
|
112 |
|
113 initialized = TRUE;*/ |
|
114 |
|
115 } |
|
116 |
|
117 #else /* LM_NO_DEBUG */ |
|
118 |
|
119 void |
|
120 lm_debug_init (void) |
|
121 { |
|
122 } |
|
123 |
|
124 #endif /* LM_NO_DEBUG */ |
|
125 |
|