-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlogger.h
247 lines (194 loc) · 5.96 KB
/
logger.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/**
* \file logger.h
* \brief Wsim logger module
* \author Antoine Fraboulet
* \date 2006
**/
#ifndef _LOGGER_H_
#define _LOGGER_H_
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
void logger_init(const char *output, int level);
void logger_close();
extern int logger_verbose_level;
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
void REAL_STDOUT(char* fmt, ...);
void REAL_STDERR(char* fmp, ...);
#define STDOUT(x...) REAL_STDOUT(x)
#define STDERR(x...) REAL_STDERR(x)
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
/*
* Verbose level
*
* 0 - ERROR / MESSAGES
* 1 - WARNING
* 2 - INFO
* 3 -
* 4 -
* 5 - HW_DMSG - hardware related messages
* - mcu
* - mcu devices
* - external devices
* - platform
* - misc
* 6 - LIB_DMSG -
* - ELF loader
* - WSNet protocol dump
* - GDB engine
* - GUI backend
* - tracer
* - logpkt
* - etracer
* -
*/
/* ERROR is equal to 0 in mingw32 headers (Windows) */
#if defined(ERROR)
#undef ERROR
#endif
void OUTPUT(char* fmt, ...); // verbose 0
void ERROR (char* fmt, ...); // verbose 0
#define OUTPUT_BOXS(x...) OUTPUT(",----\n" x);
#define OUTPUT_BOXM(x...) OUTPUT("| " x);
#define OUTPUT_BOXE(x...) OUTPUT("`----\n" x);
#define OUTPUT_STATS_START(x...) OUTPUT_BOXS(x)
#define OUTPUT_STATS(x...) OUTPUT_BOXM(x)
#define OUTPUT_STATS_STOP(x...) OUTPUT_BOXE(x)
#if defined(VERBOSE_IS_A_FUNC)
#else
#define VERBOSE(level, x...) \
do { \
if (logger_verbose_level >= level) \
{ \
OUTPUT(x); \
} \
} while (0)
#endif
#define MESSAGE(x...) VERBOSE(0,x)
#define WARNING(x...) VERBOSE(1,x)
#define INFO(x...) VERBOSE(2,x)
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
#if defined(XCODE_DEBUG)
#define SW_DMSG(x...) VERBOSE(2,x)
#define DEBUG_SW_MEM 0
#define DEBUG_SW_BRK 0
#else
#define SW_DMSG(x...) do {} while(0)
#endif
#if DEBUG_SW_MEM != 0
# define SW_DMSG_MEM(x...) SW_DMSG(x)
#else
# define SW_DMSG_MEM(x...) do { } while (0)
#endif
#if DEBUG_SW_BRK != 0
# define SW_DMSG_BRK(x...) SW_DMSG(x)
#else
# define SW_DMSG_BRK(x...) do { } while (0)
#endif
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
#if defined(DEBUG)
#define HW_DMSG(x...) VERBOSE(5,x)
#define DEBUG_MCU 0
#define DEBUG_MCUDEV 0
#define DEBUG_EXTDEV 0
#define DEBUG_PLATFORM 0
#define DEBUG_MISC 0
#else
#define HW_DMSG(x...) do {} while(0)
#endif
#if DEBUG_MCU != 0
# define HW_DMSG_MCU(x...) HW_DMSG(x)
#else
# define HW_DMSG_MCU(x...) do { } while (0)
#endif
#if DEBUG_MCUDEV != 0
# define HW_DMSG_MCUDEV(x...) HW_DMSG(x)
#else
# define HW_DMSG_MCUDEV(x...) do { } while (0)
#endif
#if DEBUG_EXTDEV != 0
# define HW_DMSG_DEV(x...) HW_DMSG(x)
#else
# define HW_DMSG_DEV(x...) do { } while (0)
#endif
#if DEBUG_PLATFORM != 0
# define HW_DMSG_PLATFORM(x...) HW_DMSG(x)
#else
# define HW_DMSG_PLATFORM(x...) do { } while (0)
#endif
#if DEBUG_MISC != 0
# define HW_DMSG_MISC(x...) HW_DMSG(x)
#else
# define HW_DMSG_MISC(x...) do { } while (0)
#endif
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
#if defined(DEBUG)
#define DMSG_LIB(x...) VERBOSE(6,x)
#define DEBUG_UI 0
#define DEBUG_SELECT 0
#define DEBUG_GDB_SRP_PROTO 0 /* Serial remote protocol commands / replies */
#define DEBUG_GDB_CMD 0 /* GDB detailed debug of commands and actions */
#define DEBUG_iHEX 0
#define DEBUG_LIBWSNET 0
#define DEBUG_LIB_ELF 0
#define DEBUG_LIB_ELF_DMP 0
#else
#define DMSG_LIB(x...) do {} while(0)
#endif
#if DEBUG_UI != 0
# define DMSG_LIB_UI(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_UI(x...) do { } while (0)
#endif
#if DEBUG_SELECT != 0
# define DMSG_LIB_SELECT(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_SELECT(x...) do { } while (0)
#endif
#if DEBUG_GDB_CMD != 0
# define DMSG_LIB_GDB_CMD(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_GDB_CMD(x...) do { } while (0)
#endif
#if DEBUG_GDB_SRP_PROTO != 0
# define DMSG_LIB_GDB(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_GDB(x...) do { } while (0)
#endif
#if DEBUG_iHEX != 0
# define DMSG_LIB_iHEX(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_iHEX(x...) do { } while (0)
#endif
#if DEBUG_LIBWSNET != 0
# define DMSG_LIB_WSNET(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_WSNET(x...) do { } while (0)
#endif
#if DEBUG_LIB_ELF != 0
# define DMSG_LIB_ELF(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_ELF(x...) do { } while (0)
#endif
#if DEBUG_LIB_ELF_DMP != 0
# define DMSG_LIB_ELF_DMP(x...) DMSG_LIB(x)
#else
# define DMSG_LIB_ELF_DMP(x...) do { } while (0)
#endif
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
/* ************************************************** */
#endif