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 #ifndef UCX_LOGGING_H
35 #define UCX_LOGGING_H
36
37 #include "ucx.h"
38 #include "map.h"
39 #include "string.h"
40 #include <stdio.h>
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46
47
48
49 #define UCX_LOGGER_ERROR 0x00
50
51
52 #define UCX_LOGGER_WARN 0x10
53
54
55 #define UCX_LOGGER_INFO 0x20
56
57
58 #define UCX_LOGGER_DEBUG 0x30
59
60
61 #define UCX_LOGGER_TRACE 0x40
62
63
64
65
66
67
68 #define UCX_LOGGER_LEVEL 0x01
69
70
71
72
73
74
75 #define UCX_LOGGER_TIMESTAMP 0x02
76
77
78
79
80
81
82
83 #define UCX_LOGGER_SOURCE 0x04
84
85
86
87
88 typedef struct {
89
90 void *stream;
91
92
93
94
95
96
97 write_func writer;
98
99
100
101
102
103
104 char *dateformat;
105
106
107
108
109
110
111 unsigned int level;
112
113
114
115
116
117
118
119 unsigned int mask;
120
121
122
123
124
125
126
127
128
129
130
131
132 UcxMap* levels;
133 } UcxLogger;
134
135
136
137
138
139
140
141
142 UcxLogger *ucx_logger_new(
void *stream,
unsigned int level,
unsigned int mask);
143
144
145
146
147
148
149
150
151 void ucx_logger_free(UcxLogger* logger);
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 void ucx_logger_logf(UcxLogger *logger,
unsigned int level,
const char* file,
177 const unsigned int line,
const char* format, ...);
178
179
180
181
182
183
184
185
186 #define ucx_logger_log(logger, level, ...) \
187 ucx_logger_logf(logger, level,
__FILE__,
__LINE__,
__VA_ARGS__)
188
189
190
191
192
193
194
195 #define ucx_logger_error(logger, ...) \
196 ucx_logger_log(logger,
UCX_LOGGER_ERROR,
__VA_ARGS__)
197
198
199
200
201
202
203
204 #define ucx_logger_info(logger, ...) \
205 ucx_logger_log(logger,
UCX_LOGGER_INFO,
__VA_ARGS__)
206
207
208
209
210
211
212
213 #define ucx_logger_warn(logger, ...) \
214 ucx_logger_log(logger,
UCX_LOGGER_WARN,
__VA_ARGS__)
215
216
217
218
219
220
221
222 #define ucx_logger_debug(logger, ...) \
223 ucx_logger_log(logger,
UCX_LOGGER_DEBUG,
__VA_ARGS__)
224
225
226
227
228
229
230
231 #define ucx_logger_trace(logger, ...) \
232 ucx_logger_log(logger,
UCX_LOGGER_TRACE,
__VA_ARGS__)
233
234 #ifdef __cplusplus
235 }
236 #endif
237
238 #endif
239