-
Notifications
You must be signed in to change notification settings - Fork 28
/
mible_log_internal.h
99 lines (84 loc) · 4.28 KB
/
mible_log_internal.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
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
88
89
90
91
92
93
94
95
96
97
98
#ifndef __MIBLE_LOG_INTERNAL__H__
#define __MIBLE_LOG_INTERNAL__H__
#ifndef MI_LOG_COLORS_ENABLE
#define MI_LOG_COLORS_ENABLE 0
#endif
#ifndef MI_LOG_MODULE_NAME
#define MI_LOG_MODULE_NAME ""
#endif
#define MI_LOG_LEVEL_ERROR 1U
#define MI_LOG_LEVEL_WARNING 2U
#define MI_LOG_LEVEL_INFO 3U
#define MI_LOG_LEVEL_DEBUG 4U
#if MI_LOG_COLORS_ENABLE
#define MI_LOG_COLOR_DEFAULT "\x1B[0m"
#define MI_LOG_COLOR_BLACK "\x1B[1;30m"
#define MI_LOG_COLOR_RED "\x1B[1;31m"
#define MI_LOG_COLOR_GREEN "\x1B[1;32m"
#define MI_LOG_COLOR_YELLOW "\x1B[1;33m"
#define MI_LOG_COLOR_BLUE "\x1B[1;34m"
#define MI_LOG_COLOR_MAGENTA "\x1B[1;35m"
#define MI_LOG_COLOR_CYAN "\x1B[1;36m"
#define MI_LOG_COLOR_WHITE "\x1B[1;37m"
#else
#define MI_LOG_COLOR_DEFAULT
#define MI_LOG_COLOR_BLACK
#define MI_LOG_COLOR_RED
#define MI_LOG_COLOR_GREEN
#define MI_LOG_COLOR_YELLOW
#define MI_LOG_COLOR_BLUE
#define MI_LOG_COLOR_MAGENTA
#define MI_LOG_COLOR_CYAN
#define MI_LOG_COLOR_WHITE
#endif
#define MI_LOG_ERROR_COLOR MI_LOG_COLOR_RED
#define MI_LOG_WARNING_COLOR MI_LOG_COLOR_YELLOW
#define MI_LOG_INFO_COLOR MI_LOG_COLOR_DEFAULT
#define MI_LOG_DEBUG_COLOR MI_LOG_COLOR_GREEN
#define MI_LOG_DEFAULT_COLOR MI_LOG_COLOR_DEFAULT
#define MI_LOG_BREAK ": "
#define MI_ERROR_PREFIX MI_LOG_ERROR_COLOR "[E] " MI_LOG_MODULE_NAME MI_LOG_BREAK
#define MI_WARNING_PREFIX MI_LOG_WARNING_COLOR "[W] " MI_LOG_MODULE_NAME MI_LOG_BREAK
#define MI_INFO_PREFIX MI_LOG_INFO_COLOR "[I] " MI_LOG_MODULE_NAME MI_LOG_BREAK
#define MI_DEBUG_PREFIX MI_LOG_DEBUG_COLOR "[D] " MI_LOG_MODULE_NAME MI_LOG_BREAK
#if !defined(MI_PRINTF)
#error "Not defined printf function."
#elif !defined(MI_HEXDUMP)
#error "Not defined hexdump function."
#endif
#define MI_LOG_INTERNAL_ERROR(_fmt_, ...) \
do { \
if (MI_LOG_LEVEL >= MI_LOG_LEVEL_ERROR) \
{ \
MI_PRINTF(MI_ERROR_PREFIX _fmt_ MI_LOG_DEFAULT_COLOR, ##__VA_ARGS__); \
} \
} while(0)
#define MI_LOG_INTERNAL_WARNING(_fmt_, ...) \
do { \
if (MI_LOG_LEVEL >= MI_LOG_LEVEL_WARNING) \
{ \
MI_PRINTF(MI_WARNING_PREFIX _fmt_ MI_LOG_DEFAULT_COLOR, ##__VA_ARGS__); \
} \
} while(0)
#define MI_LOG_INTERNAL_INFO(_fmt_, ...) \
do { \
if (MI_LOG_LEVEL >= MI_LOG_LEVEL_INFO) \
{ \
MI_PRINTF(MI_INFO_PREFIX _fmt_ MI_LOG_DEFAULT_COLOR, ##__VA_ARGS__); \
} \
} while(0)
#define MI_LOG_INTERNAL_DEBUG(_fmt_, ...) \
do { \
if (MI_LOG_LEVEL >= MI_LOG_LEVEL_DEBUG) \
{ \
MI_PRINTF(MI_DEBUG_PREFIX _fmt_ MI_LOG_DEFAULT_COLOR, ##__VA_ARGS__); \
} \
} while(0)
#define MI_LOG_INTERNAL_HEXDUMP(p_data, len) \
do { \
if (MI_LOG_LEVEL >= MI_LOG_LEVEL_DEBUG) \
{ \
MI_HEXDUMP(p_data, len); \
} \
} while(0)
#endif // __MIBLE_LOG_INTERNAL__H__