-
Notifications
You must be signed in to change notification settings - Fork 2
/
Debug.h
50 lines (40 loc) · 1.29 KB
/
Debug.h
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
#ifdef __cplusplus
extern "C"
{
#endif
#define ERROR_LOG 1
#define COMM_LOG 2
#define Q_PLAN_LOG 3
#define DEBUG 1
#ifdef DEBUG
#define DEBUG_TEST 1
#else
#define DEBUG_TEST 0
#endif
#define debug_print(level, logtype, fmt, ...) \
do { if (DEBUG_TEST) \
{ \
if (level==0) break; \
else if (level==1) { switch(logtype) { \
case ERROR_LOG: printf("%s:%d: ERROR_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break;\
} } \
else if (level<=2) { switch(logtype) { \
case ERROR_LOG: printf("%s:%d: ERROR_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break; \
case COMM_LOG: printf("%s:%d: COMM_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break;\
} }\
else if (level<=3 && level>=1) { switch(logtype) { \
case ERROR_LOG: printf("%s:%d: ERROR_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break;\
case COMM_LOG: printf("%s:%d: COMM_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break;\
case Q_PLAN_LOG: printf("%s:%d: Q_PLAN_LOG: %s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); break;\
} }\
} \
} while (0)
#ifdef __cplusplus
}
#endif