author | Samuel Tesla <stesla@engineyard.com> |
Mon, 09 Mar 2009 18:05:59 -0500 | |
changeset 593 | 2c04915af500 |
parent 518 | cdd6a0c5b439 |
child 599 | 7207d1dbb86b |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
1 | 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[] = { |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
29 |
{"VERBOSE", LM_LOG_LEVEL_VERBOSE}, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
30 |
{"NET", LM_LOG_LEVEL_NET}, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
31 |
{"PARSER", LM_LOG_LEVEL_PARSER}, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
32 |
{"SSL", LM_LOG_LEVEL_SSL}, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
33 |
{"SASL", LM_LOG_LEVEL_SASL}, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
34 |
{"ALL", LM_LOG_LEVEL_ALL} |
1 | 35 |
}; |
36 |
||
37 |
#define NUM_DEBUG_KEYS (sizeof (debug_keys) / sizeof (GDebugKey)) |
|
38 |
||
39 |
static void |
|
40 |
debug_log_handler (const gchar *log_domain, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
41 |
GLogLevelFlags log_level, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
42 |
const gchar *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
43 |
gpointer user_data) |
1 | 44 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
45 |
if (debug_flags & log_level) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
46 |
if (log_level & LM_LOG_LEVEL_VERBOSE) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
47 |
g_print ("*** "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
48 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
49 |
else if (log_level & LM_LOG_LEVEL_PARSER) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
50 |
g_print ("LM-PARSER: "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
51 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
52 |
else if (log_level & LM_LOG_LEVEL_SASL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
53 |
g_print ("LM-SASL: "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
54 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
55 |
else if (log_level & LM_LOG_LEVEL_SSL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
56 |
g_print ("LM-SSL: "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
57 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
58 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
59 |
g_print ("%s", message); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
60 |
} |
1 | 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 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
71 |
const gchar *env_lm_debug; |
1 | 72 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
73 |
if (initialized) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
74 |
return; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
75 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
76 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
77 |
env_lm_debug = g_getenv ("LM_DEBUG"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
78 |
if (env_lm_debug) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
79 |
debug_flags = g_parse_debug_string (env_lm_debug, debug_keys, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
80 |
NUM_DEBUG_KEYS); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
81 |
} |
1 | 82 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
83 |
g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
84 |
debug_log_handler, NULL); |
1 | 85 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
86 |
initialized = TRUE; |
1 | 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 |