author | psykose <alice@ayaya.dev> |
Thu, 21 Apr 2022 20:23:32 +0200 | |
changeset 744 | 4ebe32453682 |
parent 690 | 7ccf2113ec5f |
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 |
|
690
7ccf2113ec5f
Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents:
599
diff
changeset
|
16 |
* License along with this program; if not, see <https://www.gnu.org/licenses> |
1 | 17 |
*/ |
18 |
||
19 |
#include "lm-debug.h" |
|
20 |
||
21 |
#ifndef LM_NO_DEBUG |
|
22 |
||
23 |
static LmLogLevelFlags debug_flags = 0; |
|
24 |
static gboolean initialized = FALSE; |
|
25 |
||
26 |
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
|
27 |
{"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
|
28 |
{"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
|
29 |
{"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
|
30 |
{"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
|
31 |
{"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
|
32 |
{"ALL", LM_LOG_LEVEL_ALL} |
1 | 33 |
}; |
34 |
||
35 |
#define NUM_DEBUG_KEYS (sizeof (debug_keys) / sizeof (GDebugKey)) |
|
36 |
||
37 |
static void |
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
gpointer user_data) |
1 | 42 |
{ |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
} |
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 |
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
|
48 |
g_print ("LM-PARSER: "); |
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
49 |
} |
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
|
50 |
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
|
51 |
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
|
52 |
} |
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 |
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
|
54 |
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
|
55 |
} |
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
56 |
|
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
|
57 |
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
|
58 |
} |
1 | 59 |
} |
60 |
||
19
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
61 |
/** |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
62 |
* lm_debug_init |
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 |
* Initialized the debug system. |
bb3195f74ac7
2003-07-17 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
65 |
**/ |
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
66 |
void |
1 | 67 |
lm_debug_init (void) |
68 |
{ |
|
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
|
69 |
const gchar *env_lm_debug; |
1 | 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 |
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
|
72 |
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
|
73 |
} |
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
74 |
|
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
} |
1 | 80 |
|
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
81 |
g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL, |
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
|
82 |
debug_log_handler, NULL); |
1 | 83 |
|
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
|
84 |
initialized = TRUE; |
1 | 85 |
} |
348
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
86 |
|
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
87 |
#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
|
88 |
|
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
89 |
static void |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
90 |
do_nothing_log_handler (const gchar *log_domain, |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
91 |
GLogLevelFlags log_level, |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
92 |
const gchar *message, |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
93 |
gpointer user_data) |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
94 |
{ |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
95 |
} |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
96 |
|
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
97 |
void |
348
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
98 |
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
|
99 |
{ |
599
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
100 |
g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL, |
7207d1dbb86b
Fix g_log issue when configured with --enable-debug=no.
Samuel Tesla <stesla@engineyard.com>
parents:
518
diff
changeset
|
101 |
do_nothing_log_handler, NULL); |
348
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
102 |
} |
48fdfa327cc7
Make the 1.3 branch build with --disable-debug again. Fixes LM-113.
Martyn Russell <martyn@imendio.com>
parents:
255
diff
changeset
|
103 |
|
1 | 104 |
#endif /* LM_NO_DEBUG */ |
105 |