ubinos
logm.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Sung Ho Park
3  Contact: ubinos.org@gmail.com
4 
5  This file is part of the itf_ubinos component of the Ubinos.
6 
7  GNU General Public License Usage
8  This file may be used under the terms of the GNU
9  General Public License version 3.0 as published by the Free Software
10  Foundation and appearing in the file license_gpl3.txt included in the
11  packaging of this file. Please review the following information to
12  ensure the GNU General Public License version 3.0 requirements will be
13  met: http://www.gnu.org/copyleft/gpl.html.
14 
15  GNU Lesser General Public License Usage
16  Alternatively, this file may be used under the terms of the GNU Lesser
17  General Public License version 2.1 as published by the Free Software
18  Foundation and appearing in the file license_lgpl.txt included in the
19  packaging of this file. Please review the following information to
20  ensure the GNU Lesser General Public License version 2.1 requirements
21  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22 
23  Commercial Usage
24  Alternatively, licensees holding valid commercial licenses may
25  use this file in accordance with the commercial license agreement
26  provided with the software or, alternatively, in accordance with the
27  terms contained in a written agreement between you and rightful owner.
28  */
29 
30 #ifndef UBICLIB_LOGM_H_
31 #define UBICLIB_LOGM_H_
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
46 #include <ubinos_config.h>
47 #include <ubinos/type.h>
48 
50 #define LOGM_CATEGORY__ALL 0
51 
52 #define LOGM_CATEGORY__DEFAULT 1
53 
54 #define LOGM_CATEGORY__HEAP 2
55 
56 #define LOGM_CATEGORY__BITMAP 3
57 
58 #define LOGM_CATEGORY__USER00 4
59 
60 #define LOGM_CATEGORY__USER01 5
61 
62 #define LOGM_CATEGORY__USER02 6
63 
64 #define LOGM_CATEGORY__END 7
65 
67 #define LOGM_LEVEL__NONE 0
68 
69 #define LOGM_LEVEL__ALWAYS 1
70 
71 #define LOGM_LEVEL__FATAL 2
72 
73 #define LOGM_LEVEL__ERROR 3
74 
75 #define LOGM_LEVEL__WARNING 4
76 
77 #define LOGM_LEVEL__INFO 5
78 
79 #define LOGM_LEVEL__DEBUG 6
80 
81 #define LOGM_LEVEL__END 7
82 
84 #define LOGM_CATEGORY LOGM_CATEGORY__DEFAULT
85 
86 #define LOGM_LEVEL LOGM_LEVEL__WARNING
87 
88 #define LOGM_TAG NULL
89 
90 #if !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1)
91 
104 int logm_setlevel(int category, int level);
105 
116 int logm_getlevel(int category);
117 
135 int logm_printf(int category, int level, const char * tag, const char * format, ...);
136 
151 int logm_print(int category, int level, const char * tag, const char * msg);
152 
168 int snprintf(char * str, size_t num, const char * format, ...);
169 
171 #define logma(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__ALWAYS, LOGM_TAG, msg)
172 
173 #define logmt(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__FATAL, LOGM_TAG, msg)
174 
175 #define logme(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__ERROR, LOGM_TAG, msg)
176 
177 #define logmw(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__WARNING, LOGM_TAG, msg)
178 
179 #define logmi(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__INFO, LOGM_TAG, msg)
180 
181 #define logmd(msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL__DEBUG, LOGM_TAG, msg)
182 
183 #define logm (msg) logm_print(LOGM_CATEGORY, LOGM_LEVEL, LOGM_TAG, msg)
184 
186 #define logmfa(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__ALWAYS, LOGM_TAG, format, ## args)
187 
188 #define logmft(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__FATAL, LOGM_TAG, format, ## args)
189 
190 #define logmfe(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__ERROR, LOGM_TAG, format, ## args)
191 
192 #define logmfw(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__WARNING, LOGM_TAG, format, ## args)
193 
194 #define logmfi(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__INFO, LOGM_TAG, format, ## args)
195 
196 #define logmfd(format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL__DEBUG, LOGM_TAG, format, ## args)
197 
198 #define logmf (format, args...) logm_printf(LOGM_CATEGORY, LOGM_LEVEL, LOGM_TAG, format, ## args)
199 
200 #else /* !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1) */
201 
214 #define logm_setlevel(category, level) ((void) (LOGM_LEVEL__NONE))
215 
226 #define logm_getlevel(category) ((void) (LOGM_LEVEL__NONE))
227 
245 #define logm_printf(category, level, tag, format, args...)
246 
248 #define logma(msg)
249 
250 #define logmt(msg)
251 
252 #define logme(msg)
253 
254 #define logmw(msg)
255 
256 #define logmi(msg)
257 
258 #define logmd(msg)
259 
260 #define logm (msg)
261 
263 #define logmfa(format, args...)
264 
265 #define logmft(format, args...)
266 
267 #define logmfe(format, args...)
268 
269 #define logmfw(format, args...)
270 
271 #define logmfi(format, args...)
272 
273 #define logmfd(format, args...)
274 
275 #define logmf (format, args...)
276 
277 #endif /* !(UBINOS__UBICLIB__EXCLUDE_LOGM == 1) */
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* UBICLIB_LOGM_H_ */
snprintf
int snprintf(char *str, size_t num, const char *format,...)
logm_printf
int logm_printf(int category, int level, const char *tag, const char *format,...)
logm_getlevel
int logm_getlevel(int category)
type.h
ubinos basic data type
logm_setlevel
int logm_setlevel(int category, int level)
logm_print
int logm_print(int category, int level, const char *tag, const char *msg)