3 /* log - a generic logging facility in the spirit of log4j */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003, 2004 Martin Quinson. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 /* GRAS_LOG_MAYDAY: define this to replace the logging facilities with basic
12 printf function. Useful to debug the logging facilities themselves */
13 #undef GRAS_LOG_MAYDAY
14 //#define GRAS_LOG_MAYDAY
23 * gras_log_priority_t:
24 * @gras_log_priority_none: used internally (don't poke with)
25 * @gras_log_priority_debug: crufty output
26 * @gras_log_priority_verbose: verbose output for the user wanting more
27 * @gras_log_priority_info: output about the regular functionning
28 * @gras_log_priority_warning: minor issue encountered
29 * @gras_log_priority_error: issue encountered
30 * @gras_log_priority_critical: major issue encountered
31 * @gras_log_priority_infinite: value for GRAS_LOG_STATIC_THRESHOLD to not log
32 * @gras_log_priority_uninitialized: used internally (don't poke with)
34 * The different existing priorities.
37 gras_log_priority_none = 0,
38 gras_log_priority_trace = 1,
39 gras_log_priority_debug = 2,
40 gras_log_priority_verbose = 3,
41 gras_log_priority_info = 4,
42 gras_log_priority_warning = 5,
43 gras_log_priority_error = 6,
44 gras_log_priority_critical = 7,
46 gras_log_priority_infinite = 8,
48 gras_log_priority_uninitialized = -1
49 } gras_log_priority_t;
55 * All logging facilities are disabled at compilation time
60 * GRAS_LOG_STATIC_THRESHOLD:
62 * All logging with priority < GRAS_LOG_STATIC_THRESHOLD is disabled at
63 * compile time, i.e., compiled out.
66 # define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_infinite
69 #ifndef GRAS_LOG_STATIC_THRESHOLD
70 # define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_none
72 #endif /* !defined(NLOG) */
74 /* Transforms a category name to a global variable name. */
75 #define _GRAS_LOGV(cat) _GRAS_LOG_CONCAT(_gras_this_log_category_does_not_exist__, cat)
76 #define _GRAS_LOG_CONCAT(x,y) x ## y
78 /* The root of the category hierarchy. */
79 #define GRAS_LOG_ROOT_CAT root
82 * GRAS_LOG_NEW_SUBCATEGORY:
83 * @catName: name of new category
84 * @parent: father of the new category in the tree
86 * Defines a new subcategory of the parent.
89 #define GRAS_LOG_NEW_SUBCATEGORY(catName, parent) \
90 extern gras_log_category_t _GRAS_LOGV(parent); \
91 gras_log_category_t _GRAS_LOGV(catName) = { \
92 &_GRAS_LOGV(parent), 0, 0, \
93 #catName, gras_log_priority_uninitialized, 1, \
96 //#else /* No logging at all, please */
97 //#define GRAS_LOG_NEW_SUBCATEGORY(catName,parent)
101 * GRAS_LOG_NEW_CATEGORY:
102 * @catName: name of new category
104 * Creates a new subcategory of the root category.
106 #define GRAS_LOG_NEW_CATEGORY(catName) GRAS_LOG_NEW_SUBCATEGORY(catName, GRAS_LOG_ROOT_CAT)
109 * GRAS_LOG_DEFAULT_CATEGORY:
110 * @cname: name of the cat
112 * Indicates which category is the default one.
115 #if defined(GRAS_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
116 # define GRAS_LOG_DEFAULT_CATEGORY(cname)
118 # define GRAS_LOG_DEFAULT_CATEGORY(cname) \
119 static gras_log_category_t* _GRAS_LOGV(default) = &_GRAS_LOGV(cname)
123 * GRAS_LOG_NEW_DEFAULT_CATEGORY:
124 * @cname: name of the cat
126 * Creates a new subcategory of the root category and makes it the default
127 * (used by macros that don't explicitly specify a category).
129 #define GRAS_LOG_NEW_DEFAULT_CATEGORY(cname) \
130 GRAS_LOG_NEW_CATEGORY(cname) \
131 GRAS_LOG_DEFAULT_CATEGORY(cname)
134 * GRAS_LOG_NEW_DEFAULT_SUBCATEGORY:
135 * @cname: name of the cat
136 * @parent: name of the parent
138 * Creates a new subcategory of the parent category and makes it the default
139 * (used by macros that don't explicitly specify a category).
141 #define GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent) \
142 GRAS_LOG_NEW_SUBCATEGORY(cname, parent) \
143 GRAS_LOG_DEFAULT_CATEGORY(cname)
146 * GRAS_LOG_EXTERNAL_CATEGORY:
147 * @cname: name of the cat
149 * Indicates that a category you'll use in this file (to get subcategories of it,
150 * for example) really lives in another file.
153 #define GRAS_LOG_EXTERNAL_CATEGORY(cname) \
154 extern gras_log_category_t _GRAS_LOGV(cname)
156 // Functions you may call
158 extern gras_error_t gras_log_control_set(const char* cs);
160 // Forward declarations
161 typedef struct gras_log_appender_s gras_log_appender_t;
162 typedef struct gras_log_event_s gras_log_event_t;
163 typedef struct gras_log_category_s gras_log_category_t;
166 * Do NOT access any members of this structure directly.
168 struct gras_log_category_s {
169 gras_log_category_t *parent;
170 /*@null@*/ gras_log_category_t *firstChild;
171 /*@null@*/ gras_log_category_t *nextSibling;
174 int isThreshInherited;
175 /*@null@*/ gras_log_appender_t *appender;
180 struct gras_log_appender_s {
181 void (*do_append) (gras_log_appender_t* thisLogAppender,
182 gras_log_event_t* event, const char *fmt);
186 struct gras_log_event_s {
187 gras_log_category_t* cat;
188 gras_log_priority_t priority;
189 const char* fileName;
190 const char* functionName;
196 * gras_log_threshold_set:
197 * @cat: the category (not only its name, but the variable)
198 * @thresholdPriority: the priority
200 * Programatically alters a category's threshold priority (don't use).
202 extern void gras_log_threshold_set(gras_log_category_t* cat,
203 gras_log_priority_t thresholdPriority);
206 * gras_log_parent_set:
207 * @cat: the category (not only its name, but the variable)
208 * @parent: the parent cat
210 * Programatically alter a category's parent (don't use).
212 extern void gras_log_parent_set(gras_log_category_t* cat,
213 gras_log_category_t* parent);
216 * gras_log_appender_set:
217 * @cat: the category (not only its name, but the variable)
220 * Programatically sets the category's appender (don't use).
222 extern void gras_log_appender_set(gras_log_category_t* cat,
223 gras_log_appender_t* app);
225 // Functions that you shouldn't call.
226 extern void _gras_log_event_log(gras_log_event_t*ev,
230 __attribute__ ((format (printf, 2, 3)))
234 extern int _gras_log_cat_init(gras_log_priority_t priority,
235 gras_log_category_t* category);
238 extern gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT);
239 GRAS_LOG_EXTERNAL_CATEGORY(GRAS);
240 extern gras_log_appender_t *gras_log_default_appender;
243 * GRAS_LOG_ISENABLED:
244 * @catName: name of the category
245 * @priority: minimal priority to be enabled to return true
247 * Returns true if the given priority is enabled for the category.
248 * If you have expensive expressions that are computed outside of the log
249 * command and used only within it, you should make its evaluation conditional
252 #define GRAS_LOG_ISENABLED(catName, priority) \
253 _GRAS_LOG_ISENABLEDV(_GRAS_LOGV(catName), priority)
256 * Helper function that implements GRAS_LOG_ISENABLED.
259 * First part is a compile-time constant.
260 * Call to _log_initCat only happens once.
262 #define _GRAS_LOG_ISENABLEDV(catv, priority) \
263 (priority >= GRAS_LOG_STATIC_THRESHOLD \
264 && priority >= catv.threshold \
265 && (catv.threshold != gras_log_priority_uninitialized \
266 || _gras_log_cat_init(priority, &catv)) )
270 * Some kludge macros to ease maintenance. See how they're used below.
272 * IMPLEMENTATION NOTE: To reduce the parameter passing overhead of an enabled
273 * message, the many parameters passed to the logging function are packed in a
274 * structure. Since these values will be usually be passed to at least 3
275 * functions, this is a win.
276 * It also allows adding new values (such as a timestamp) without breaking
278 * Setting the LogEvent's valist member is done inside _log_logEvent.
281 #define _GRAS_LOG_PRE(catv, priority) do { \
282 if (_GRAS_LOG_ISENABLEDV(catv, priority)) { \
283 gras_log_event_t _log_ev = \
284 {&(catv),priority,__FILE__,__FUNCTION__,__LINE__}; \
285 _gras_log_event_log(&_log_ev
287 #define _GRAS_LOG_POST \
294 #ifdef GRAS_LOG_MAYDAY
295 # define CLOG0(c, p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
296 # define CLOG1(c, p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
297 # define CLOG2(c, p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
298 # define CLOG3(c, p, f,a1,a2,a3) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)
299 # define CLOG4(c, p, f,a1,a2,a3,a4) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)
300 # define CLOG5(c, p, f,a1,a2,a3,a4,a5) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)
301 # define CLOG6(c, p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
302 # define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7)
303 # define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8)
305 # define CLOG0(c, p, f) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f _GRAS_LOG_POST
306 # define CLOG1(c, p, f,a1) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1 _GRAS_LOG_POST
307 # define CLOG2(c, p, f,a1,a2) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2 _GRAS_LOG_POST
308 # define CLOG3(c, p, f,a1,a2,a3) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3 _GRAS_LOG_POST
309 # define CLOG4(c, p, f,a1,a2,a3,a4) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
310 # define CLOG5(c, p, f,a1,a2,a3,a4,a5) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5 _GRAS_LOG_POST
311 # define CLOG6(c, p, f,a1,a2,a3,a4,a5,a6) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6 _GRAS_LOG_POST
312 # define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7 _GRAS_LOG_POST
313 # define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _GRAS_LOG_POST
316 #define CDEBUG0(c, f) CLOG0(c, gras_log_priority_debug, f)
317 #define CDEBUG1(c, f,a1) CLOG1(c, gras_log_priority_debug, f,a1)
318 #define CDEBUG2(c, f,a1,a2) CLOG2(c, gras_log_priority_debug, f,a1,a2)
319 #define CDEBUG3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_debug, f,a1,a2,a3)
320 #define CDEBUG4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_debug, f,a1,a2,a3,a4)
321 #define CDEBUG5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5)
322 #define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
323 #define CDEBUG7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
324 #define CDEBUG8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
326 #define CVERB0(c, f) CLOG0(c, gras_log_priority_verbose, f)
327 #define CVERB1(c, f,a1) CLOG1(c, gras_log_priority_verbose, f,a1)
328 #define CVERB2(c, f,a1,a2) CLOG2(c, gras_log_priority_verbose, f,a1,a2)
329 #define CVERB3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_verbose, f,a1,a2,a3)
330 #define CVERB4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_verbose, f,a1,a2,a3,a4)
331 #define CVERB5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
332 #define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
334 #define CINFO0(c, f) CLOG0(c, gras_log_priority_info, f)
335 #define CINFO1(c, f,a1) CLOG1(c, gras_log_priority_info, f,a1)
336 #define CINFO2(c, f,a1,a2) CLOG2(c, gras_log_priority_info, f,a1,a2)
337 #define CINFO3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_info, f,a1,a2,a3)
338 #define CINFO4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_info, f,a1,a2,a3,a4)
339 #define CINFO5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_info, f,a1,a2,a3,a4,a5)
340 #define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
342 #define CWARN0(c, f) CLOG0(c, gras_log_priority_warning, f)
343 #define CWARN1(c, f,a1) CLOG1(c, gras_log_priority_warning, f,a1)
344 #define CWARN2(c, f,a1,a2) CLOG2(c, gras_log_priority_warning, f,a1,a2)
345 #define CWARN3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_warning, f,a1,a2,a3)
346 #define CWARN4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_warning, f,a1,a2,a3,a4)
347 #define CWARN5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5)
348 #define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
350 #define CERROR0(c, f) CLOG0(c, gras_log_priority_error, f)
351 #define CERROR1(c, f,a1) CLOG1(c, gras_log_priority_error, f,a1)
352 #define CERROR2(c, f,a1,a2) CLOG2(c, gras_log_priority_error, f,a1,a2)
353 #define CERROR3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_error, f,a1,a2,a3)
354 #define CERROR4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_error, f,a1,a2,a3,a4)
355 #define CERROR5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_error, f,a1,a2,a3,a4,a5)
356 #define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
360 * @c: the category to log into
361 * @f: the format string
362 * @a1: first argument of the format
363 * @a2: second argument of the format
364 * @a3: third argument of the format
365 * @a4: fourth argument of the format
366 * @a5: fifth argument of the format
367 * @a6: sixth argument of the format
369 * Log something to the current default category under the warning priority.
371 * The macros CCRITICAL0 ... CCRITICAL5 naturally also exist, but are not listed here
372 * for sake of clarity. They just differ in the number of arguments passed
373 * along with the format string.
376 #define CCRITICAL0(c, f) CLOG0(c, gras_log_priority_critical, f)
377 #define CCRITICAL1(c, f,a1) CLOG1(c, gras_log_priority_critical, f,a1)
378 #define CCRITICAL2(c, f,a1,a2) CLOG2(c, gras_log_priority_critical, f,a1,a2)
379 #define CCRITICAL3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_critical, f,a1,a2,a3)
380 #define CCRITICAL4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_critical, f,a1,a2,a3,a4)
381 #define CCRITICAL5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5)
382 #define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
384 #ifdef GRAS_LOG_MAYDAY
385 # define LOG0(p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
386 # define LOG1(p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
387 # define LOG2(p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
388 # define LOG3(p, f,a1,a2,a3) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)
389 # define LOG4(p, f,a1,a2,a3,a4) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)
390 # define LOG5(p, f,a1,a2,a3,a4,a5) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)
391 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
392 # define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7)
393 # define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8)
395 # define LOG0(p, f) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f _GRAS_LOG_POST
396 # define LOG1(p, f,a1) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1 _GRAS_LOG_POST
397 # define LOG2(p, f,a1,a2) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2 _GRAS_LOG_POST
398 # define LOG3(p, f,a1,a2,a3) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3 _GRAS_LOG_POST
399 # define LOG4(p, f,a1,a2,a3,a4) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
400 # define LOG5(p, f,a1,a2,a3,a4,a5) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5 _GRAS_LOG_POST
401 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6 _GRAS_LOG_POST
402 # define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7 _GRAS_LOG_POST
403 # define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _GRAS_LOG_POST
408 * @f: the format string
409 * @a1: first argument of the format
410 * @a2: second argument of the format
411 * @a3: third argument of the format
412 * @a4: fourth argument of the format
413 * @a5: fifth argument of the format
414 * @a6: sixth argument of the format
416 * Log something to the current default category under the debug priority.
418 * The macros DEBUG0 ... DEBUG5 naturally also exist, but are not listed here
419 * for sake of clarity. They just differ in the number of arguments passed
420 * along with the format string.
423 #define DEBUG0(f) LOG0(gras_log_priority_debug, f)
424 #define DEBUG1(f,a1) LOG1(gras_log_priority_debug, f,a1)
425 #define DEBUG2(f,a1,a2) LOG2(gras_log_priority_debug, f,a1,a2)
426 #define DEBUG3(f,a1,a2,a3) LOG3(gras_log_priority_debug, f,a1,a2,a3)
427 #define DEBUG4(f,a1,a2,a3,a4) LOG4(gras_log_priority_debug, f,a1,a2,a3,a4)
428 #define DEBUG5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_debug, f,a1,a2,a3,a4,a5)
429 #define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
430 #define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
431 #define DEBUG8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
435 * @f: the format string
436 * @a1: first argument of the format
437 * @a2: second argument of the format
438 * @a3: third argument of the format
439 * @a4: fourth argument of the format
440 * @a5: fifth argument of the format
441 * @a6: sixth argument of the format
443 * Log something to the current default category under the verbose priority.
445 * The macros VERB0 ... VERB5 naturally also exist, but are not listed here
446 * for sake of clarity. They just differ in the number of arguments passed
447 * along with the format string.
450 #define VERB0(f) LOG0(gras_log_priority_verbose, f)
451 #define VERB1(f,a1) LOG1(gras_log_priority_verbose, f,a1)
452 #define VERB2(f,a1,a2) LOG2(gras_log_priority_verbose, f,a1,a2)
453 #define VERB3(f,a1,a2,a3) LOG3(gras_log_priority_verbose, f,a1,a2,a3)
454 #define VERB4(f,a1,a2,a3,a4) LOG4(gras_log_priority_verbose, f,a1,a2,a3,a4)
455 #define VERB5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
456 #define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
460 * @f: the format string
461 * @a1: first argument of the format
462 * @a2: second argument of the format
463 * @a3: third argument of the format
464 * @a4: fourth argument of the format
465 * @a5: fifth argument of the format
466 * @a6: sixth argument of the format
468 * Log something to the current default category under the info priority.
470 * The macros INFO0 ... INFO5 naturally also exist, but are not listed here
471 * for sake of clarity. They just differ in the number of arguments passed
472 * along with the format string.
475 #define INFO0(f) LOG0(gras_log_priority_info, f)
476 #define INFO1(f,a1) LOG1(gras_log_priority_info, f,a1)
477 #define INFO2(f,a1,a2) LOG2(gras_log_priority_info, f,a1,a2)
478 #define INFO3(f,a1,a2,a3) LOG3(gras_log_priority_info, f,a1,a2,a3)
479 #define INFO4(f,a1,a2,a3,a4) LOG4(gras_log_priority_info, f,a1,a2,a3,a4)
480 #define INFO5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_info, f,a1,a2,a3,a4,a5)
481 #define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
485 * @f: the format string
486 * @a1: first argument of the format
487 * @a2: second argument of the format
488 * @a3: third argument of the format
489 * @a4: fourth argument of the format
490 * @a5: fifth argument of the format
491 * @a6: sixth argument of the format
493 * Log something to the current default category under the warning priority.
495 * The macros WARN0 ... WARN5 naturally also exist, but are not listed here
496 * for sake of clarity. They just differ in the number of arguments passed
497 * along with the format string.
500 #define WARN0(f) LOG0(gras_log_priority_warning, f)
501 #define WARN1(f,a1) LOG1(gras_log_priority_warning, f,a1)
502 #define WARN2(f,a1,a2) LOG2(gras_log_priority_warning, f,a1,a2)
503 #define WARN3(f,a1,a2,a3) LOG3(gras_log_priority_warning, f,a1,a2,a3)
504 #define WARN4(f,a1,a2,a3,a4) LOG4(gras_log_priority_warning, f,a1,a2,a3,a4)
505 #define WARN5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_warning, f,a1,a2,a3,a4,a5)
506 #define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
510 * @f: the format string
511 * @a1: first argument of the format
512 * @a2: second argument of the format
513 * @a3: third argument of the format
514 * @a4: fourth argument of the format
515 * @a5: fifth argument of the format
516 * @a6: sixth argument of the format
518 * Log something to the current default category under the error priority.
520 * The macros ERROR0 ... ERROR5 naturally also exist, but are not listed here
521 * for sake of clarity. They just differ in the number of arguments passed
522 * along with the format string.
525 #define ERROR0(f) LOG0(gras_log_priority_error, f)
526 #define ERROR1(f,a1) LOG1(gras_log_priority_error, f,a1)
527 #define ERROR2(f,a1,a2) LOG2(gras_log_priority_error, f,a1,a2)
528 #define ERROR3(f,a1,a2,a3) LOG3(gras_log_priority_error, f,a1,a2,a3)
529 #define ERROR4(f,a1,a2,a3,a4) LOG4(gras_log_priority_error, f,a1,a2,a3,a4)
530 #define ERROR5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_error, f,a1,a2,a3,a4,a5)
531 #define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
535 * @f: the format string
536 * @a1: first argument of the format
537 * @a2: second argument of the format
538 * @a3: third argument of the format
539 * @a4: fourth argument of the format
540 * @a5: fifth argument of the format
541 * @a6: sixth argument of the format
543 * Log something to the current default category under the critical priority.
545 * The macros CRITICAL0 ... CRITICAL5 naturally also exist, but are not listed here
546 * for sake of clarity. They just differ in the number of arguments passed
547 * along with the format string.
549 #define CRITICAL0(f) LOG0(gras_log_priority_critical, f)
550 #define CRITICAL1(f,a1) LOG1(gras_log_priority_critical, f,a1)
551 #define CRITICAL2(f,a1,a2) LOG2(gras_log_priority_critical, f,a1,a2)
552 #define CRITICAL3(f,a1,a2,a3) LOG3(gras_log_priority_critical, f,a1,a2,a3)
553 #define CRITICAL4(f,a1,a2,a3,a4) LOG4(gras_log_priority_critical, f,a1,a2,a3,a4)
554 #define CRITICAL5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_critical, f,a1,a2,a3,a4,a5)
555 #define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
558 #define GRAS_IN LOG1(gras_log_priority_trace, ">> begin of %s", __FUNCTION__)
559 #define GRAS_IN1(fmt,a) LOG2(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a)
560 #define GRAS_IN2(fmt,a,b) LOG3(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b)
561 #define GRAS_IN3(fmt,a,b,c) LOG4(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b,c)
562 #define GRAS_IN4(fmt,a,b,c,d) LOG5(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b,c,d)
563 #define GRAS_OUT LOG1(gras_log_priority_trace, "<< end of %s", __FUNCTION__)
564 #else /* if fool enough to compile without gcc */
565 #define GRAS_IN LOG0(gras_log_priority_trace, ">> begin of function")
566 #define GRAS_IN1(fmt,a) LOG2(gras_log_priority_trace, ">> begin of function " fmt, a)
567 #define GRAS_IN2(fmt,a,b) LOG3(gras_log_priority_trace, ">> begin of function " fmt, a,b)
568 #define GRAS_IN3(fmt,a,b,c) LOG4(gras_log_priority_trace, ">> begin of function " fmt, a,b,c)
569 #define GRAS_IN4(fmt,a,b,c,d) LOG5(gras_log_priority_trace, ">> begin of function " fmt, a,b,c,d)
571 #define GRAS_OUT(fmt,a) LOG0(gras_log_priority_trace, "<< end of function")
572 #endif /* end of foolness for non-gcc */
574 #endif /* ! _GRAS_LOG_H_ */