ubinos
logm.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Sung Ho Park
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef UBICLIB_LOGM_H_
8 #define UBICLIB_LOGM_H_
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
23 #include <ubinos_config.h>
24 #include <ubinos/type.h>
25 
26 
28 #define LOGM_CATEGORY__NONE 0
29 
31 #define LOGM_CATEGORY__UBINOS 1
33 #define LOGM_CATEGORY__BSP 2
35 #define LOGM_CATEGORY__UBIK 3
37 #define LOGM_CATEGORY__TASK 4
39 #define LOGM_CATEGORY__SEM 5
41 #define LOGM_CATEGORY__MSGQ 6
43 #define LOGM_CATEGORY__CONDV 7
45 #define LOGM_CATEGORY__SIGNAL 8
47 #define LOGM_CATEGORY__STIMER 9
48 
50 #define LOGM_CATEGORY__UBICLIB 10
52 #define LOGM_CATEGORY__HEAP 11
53 
55 #define LOGM_CATEGORY__UBIDRV 12
57 #define LOGM_CATEGORY__NVMEM 13
58 
60 #define LOGM_CATEGORY__RESOLVED04 14
61 #define LOGM_CATEGORY__RESOLVED05 15
62 #define LOGM_CATEGORY__RESOLVED06 16
63 #define LOGM_CATEGORY__RESOLVED07 17
64 #define LOGM_CATEGORY__RESOLVED08 18
65 #define LOGM_CATEGORY__RESOLVED09 19
66 
68 #define LOGM_CATEGORY__SYS00 20
70 #define LOGM_CATEGORY__SYS01 21
72 #define LOGM_CATEGORY__SYS02 22
74 #define LOGM_CATEGORY__SYS03 23
76 #define LOGM_CATEGORY__SYS04 24
78 #define LOGM_CATEGORY__SYS05 25
80 #define LOGM_CATEGORY__SYS06 26
82 #define LOGM_CATEGORY__SYS07 27
84 #define LOGM_CATEGORY__SYS08 28
86 #define LOGM_CATEGORY__SYS09 29
87 
89 #define LOGM_CATEGORY__USER00 30
91 #define LOGM_CATEGORY__USER01 31
93 #define LOGM_CATEGORY__USER02 32
95 #define LOGM_CATEGORY__USER03 33
97 #define LOGM_CATEGORY__USER04 34
99 #define LOGM_CATEGORY__USER05 35
101 #define LOGM_CATEGORY__USER06 36
103 #define LOGM_CATEGORY__USER07 37
105 #define LOGM_CATEGORY__USER08 38
107 #define LOGM_CATEGORY__USER09 39
108 
110 #define LOGM_CATEGORY__END 40
111 
112 
114 #define LOGM_LEVEL__SILENT 0
116 #define LOGM_LEVEL__FATAL 1
118 #define LOGM_LEVEL__ERROR 2
120 #define LOGM_LEVEL__WARNING 3
122 #define LOGM_LEVEL__INFO 4
124 #define LOGM_LEVEL__DEBUG 5
126 #define LOGM_LEVEL__VERBOSE 6
128 #define LOGM_LEVEL__END 7
129 
130 
132 #define LOGM_CATEGORY LOGM_CATEGORY__NONE
134 #define LOGM_LEVEL LOGM_LEVEL__WARNING
136 #define LOGM_TAG NULL
137 
138 
140 #define LOGM_TICK_COUNT_LENGTH 10
141 
143 #define LOGM_TAG_LENGTH 20
144 
146 #define LOGM_FUNCTION_NAME_LENGTH 40
147 
149 #define LOGM_LINE_NUMBER_LENGTH 6
150 
151 
152 #if !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1)
153 
154 
167 int logm_setlevel(int category, int level);
168 
179 int logm_getlevel(int category);
180 
200 int logm_println(int category, int level, const char * tag, const char * func, int line, const char * msg);
201 
223 int logm_printfln(int category, int level, const char * tag, const char * func, int line, const char * format, ...);
224 
225 
227 #define logm (msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL, LOGM_TAG, __FUNCTION__, __LINE__, msg)
228 
230 #define logmt(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__FATAL, LOGM_TAG, __FUNCTION__, __LINE__, msg)
231 
233 #define logme(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__ERROR, LOGM_TAG, __FUNCTION__, __LINE__, msg)
236 #define logmw(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__WARNING, LOGM_TAG, __FUNCTION__, __LINE__, msg)
237 
239 #define logmi(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__INFO, LOGM_TAG, __FUNCTION__, __LINE__, msg)
240 
242 #define logmd(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__DEBUG, LOGM_TAG, __FUNCTION__, __LINE__, msg)
243 
245 #define logmv(msg) logm_println(LOGM_CATEGORY, LOGM_LEVEL__VERBOSE, LOGM_TAG, __FUNCTION__, __LINE__, msg)
246 
247 
249 #define logmf (format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
250 
252 #define logmft(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__FATAL, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
253 
255 #define logmfe(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__ERROR, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
256 
258 #define logmfw(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__WARNING, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
259 
261 #define logmfi(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__INFO, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
262 
264 #define logmfd(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__DEBUG, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
265 
267 #define logmfv(format, args...) logm_printfln(LOGM_CATEGORY, LOGM_LEVEL__VERBOSE, LOGM_TAG, __FUNCTION__, __LINE__, format, ## args)
268 
269 
270 #else /* !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1) */
271 
272 
285 #define logm_setlevel(category, level) ((void) (LOGM_LEVEL__SILENT))
286 
297 #define logm_getlevel(category) (LOGM_LEVEL__SILENT)
298 
299 
301 #define logm (msg)
302 
304 #define logmt(msg)
305 
307 #define logme(msg)
308 
310 #define logmw(msg)
311 
313 #define logmi(msg)
314 
316 #define logmd(msg)
317 
319 #define logmv(msg)
320 
321 
323 #define logmf (format, args...)
324 
326 #define logmft(format, args...)
327 
329 #define logmfe(format, args...)
330 
332 #define logmfw(format, args...)
333 
335 #define logmfi(format, args...)
336 
338 #define logmfd(format, args...)
339 
341 #define logmfv(format, args...)
342 
343 
344 #endif /* !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1) */
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* UBICLIB_LOGM_H_ */
int logm_setlevel(int category, int level)
int logm_println(int category, int level, const char *tag, const char *func, int line, const char *msg)
int logm_printfln(int category, int level, const char *tag, const char *func, int line, const char *format,...)
int logm_getlevel(int category)
ubinos basic data type