author | Senko Rasic <senko.rasic@collabora.co.uk> |
Sun, 30 Nov 2008 10:20:08 +0100 | |
changeset 575 | daad23d59b56 |
parent 348 | 48fdfa327cc7 |
child 515 | fb0f1adfa271 |
permissions | -rw-r--r-- |
1 | 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 |
/* |
|
99
81e9d035de02
2004-10-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
84
diff
changeset
|
3 |
* Copyright (C) 2003 Imendio AB |
1 | 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 |
#ifndef LM_NO_DEBUG |
|
24 |
||
25 |
static LmLogLevelFlags debug_flags = 0; |
|
26 |
static gboolean initialized = FALSE; |
|
27 |
||
28 |
static const GDebugKey debug_keys[] = { |
|
29 |
{"VERBOSE", LM_LOG_LEVEL_VERBOSE}, |
|
30 |
{"NET", LM_LOG_LEVEL_NET}, |
|
31 |
{"PARSER", LM_LOG_LEVEL_PARSER}, |
|
213
27567fb5d37b
Use g_warning and g_log for warnings and debug printouts in OpenSSL backend.
Mikael Hallendal <micke@imendio.com>
parents:
99
diff
changeset
|
32 |
{"SSL", LM_LOG_LEVEL_SSL}, |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
33 |
{"SASL", LM_LOG_LEVEL_SASL}, |
1 | 34 |
{"ALL", LM_LOG_LEVEL_ALL} |
35 |
}; |
|
36 |
||
37 |
#define NUM_DEBUG_KEYS (sizeof (debug_keys) / sizeof (GDebugKey)) |
|
38 |
||
39 |
static void |
|
40 |
debug_log_handler (const gchar *log_domain, |
|
41 |
GLogLevelFlags log_level, |
|
42 |
const gchar *message, |
|
43 |
gpointer user_data) |
|
44 |
{ |
|
45 |
if (debug_flags & log_level) { |
|
46 |
if (log_level & LM_LOG_LEVEL_VERBOSE) { |
|
47 |
g_print ("*** "); |
|
48 |
} |
|
49 |
else if (log_level & LM_LOG_LEVEL_PARSER) { |
|
50 |
g_print ("LM-PARSER: "); |
|
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
51 |
} |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
52 |
else if (log_level & LM_LOG_LEVEL_SASL) { |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
53 |
g_print ("LM-SASL: "); |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
54 |
} |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
55 |
else if (log_level & LM_LOG_LEVEL_SSL) { |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
213
diff
changeset
|
56 |
g_print ("LM-SSL: "); |
1 | 57 |
} |
58 |
||
59 |
g_print ("%s", message); |
|
60 |
} |
|
61 |
} |
|
62 |
||
19
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
63 |
/** |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
64 |
* lm_debug_init |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
65 |
* |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
66 |
* Initialized the debug system. |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
67 |
**/ |
1 | 68 |
void |
69 |
lm_debug_init (void) |
|
70 |
{ |
|
71 |
const gchar *env_lm_debug; |
|
72 |
||
73 |
if (initialized) { |
|
74 |
return; |
|
75 |
} |
|
76 |
||
77 |
env_lm_debug = g_getenv ("LM_DEBUG"); |
|
78 |
if (env_lm_debug) { |
|
79 |
debug_flags = g_parse_debug_string (env_lm_debug, debug_keys, |
|
80 |
NUM_DEBUG_KEYS); |
|
81 |
} |
|
82 |
||
83 |
g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL, |
|
84 |
debug_log_handler, NULL); |
|
85 |
||
86 |
initialized = TRUE; |
|
87 |
} |
|
348
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
88 |
|
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
89 |
#else /* LM_NO_DEBUG */ |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
90 |
|
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
91 |
void |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
92 |
lm_debug_init (void) |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
93 |
{ |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
94 |
} |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
95 |
|
1 | 96 |
#endif /* LM_NO_DEBUG */ |
97 |