forked from rhempel/umm_malloc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbglog.h
More file actions
87 lines (75 loc) · 2.66 KB
/
dbglog.h
File metadata and controls
87 lines (75 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// ----------------------------------------------------------------------------
// dbglog.h - A set of macros that cleans up code that needs to produce debug
// or log information.
//
// See copyright notice in LICENSE.TXT
// ----------------------------------------------------------------------------
//
// There are macros to handle the following decreasing levels of detail:
//
// 6 = TRACE
// 5 = DEBUG
// 4 = CRITICAL
// 3 = ERROR
// 2 = WARNING
// 1 = INFO
// 0 = FORCE - The printf is always compiled in and is called only when
// the first parameter to the macro is non-0
//
// ----------------------------------------------------------------------------
//
// The following #define should be set up before this file is included so
// that we can be sure that the correct macros are defined.
//
// #define DBG_LOG_LEVEL x
// ----------------------------------------------------------------------------
#ifndef DBG_LOG_LEVEL
# error "DBG_LOG_LEVEL is not defined!"
#endif
// ----------------------------------------------------------------------------
//
// FIXME: Currently the macros are defined at compile time, which means that
// the debug level is fixed. It will be possible in later versions to
// set up run time control of debug info at the expense of speed and
// code size
// ----------------------------------------------------------------------------
#undef DBG_LOG_TRACE
#undef DBG_LOG_DEBUG
#undef DBG_LOG_CRITICAL
#undef DBG_LOG_ERROR
#undef DBG_LOG_WARNING
#undef DBG_LOG_INFO
#undef DBG_LOG_FORCE
// ----------------------------------------------------------------------------
#if DBG_LOG_LEVEL >= 6
# define DBG_LOG_TRACE( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_TRACE( format, ... )
#endif
#if DBG_LOG_LEVEL >= 5
# define DBG_LOG_DEBUG( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_DEBUG( format, ... )
#endif
#if DBG_LOG_LEVEL >= 4
# define DBG_LOG_CRITICAL( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_CRITICAL( format, ... )
#endif
#if DBG_LOG_LEVEL >= 3
# define DBG_LOG_ERROR( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_ERROR( format, ... )
#endif
#if DBG_LOG_LEVEL >= 2
# define DBG_LOG_WARNING( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_WARNING( format, ... )
#endif
#if DBG_LOG_LEVEL >= 1
# define DBG_LOG_INFO( format, ... ) printf( format, ## __VA_ARGS__ )
#else
# define DBG_LOG_INFO( format, ... )
#endif
#define DBG_LOG_FORCE( force, format, ... ) {if(force) {printf( format, ## __VA_ARGS__ );}}
// ----------------------------------------------------------------------------