c3b71cee37c3c361c219be4f43d104c2cc6e1ac7
[strongswan.git] / src / libstrongswan / debug.h
1 /*
2 * Copyright (C) 2006 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup debug debug
18 * @{ @ingroup libstrongswan
19 */
20
21 #ifndef DEBUG_H_
22 #define DEBUG_H_
23
24 #ifndef DEBUG_LEVEL
25 # define DEBUG_LEVEL 4
26 #endif /* DEBUG_LEVEL */
27
28 /** debug macros, they call the dbg function hook */
29 #if DEBUG_LEVEL >= 1
30 # define DBG1(fmt, ...) dbg(1, fmt, ##__VA_ARGS__)
31 #endif /* DEBUG_LEVEL */
32 #if DEBUG_LEVEL >= 2
33 # define DBG2(fmt, ...) dbg(2, fmt, ##__VA_ARGS__)
34 #endif /* DEBUG_LEVEL */
35 #if DEBUG_LEVEL >= 3
36 # define DBG3(fmt, ...) dbg(3, fmt, ##__VA_ARGS__)
37 #endif /* DEBUG_LEVEL */
38 #if DEBUG_LEVEL >= 4
39 # define DBG4(fmt, ...) dbg(4, fmt, ##__VA_ARGS__)
40 #endif /* DEBUG_LEVEL */
41
42 #ifndef DBG1
43 # define DBG1(...) {}
44 #endif
45 #ifndef DBG2
46 # define DBG2(...) {}
47 #endif
48 #ifndef DBG3
49 # define DBG3(...) {}
50 #endif
51 #ifndef DBG4
52 # define DBG4(...) {}
53 #endif
54
55 /** dbg function hook, uses dbg_default() by default */
56 extern void (*dbg) (int level, char *fmt, ...);
57
58 /** default logging function */
59 void dbg_default(int level, char *fmt, ...);
60
61 /** set the level logged by dbg_default() */
62 void dbg_default_set_level(int level);
63
64 /** set the stream logged by dbg_default() to */
65 void dbg_default_set_stream(FILE *stream);
66
67 #endif /** DEBUG_H_ @}*/