Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
NDEBUG remove also debugging logs
[simgrid.git] / include / gras / log.h
1 /* $Id$ */
2
3 /* log - a generic logging facility in the spirit of log4j                  */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003, 2004 Martin Quinson.                                 */
7
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. */
10
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
15
16
17 #ifndef _GRAS_LOG_H_
18 #define _GRAS_LOG_H_
19
20 #include <stdarg.h>
21
22 /**
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)
33  *
34  * The different existing priorities.
35  */
36 typedef enum {
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, 
45
46   gras_log_priority_infinite      = 8, 
47
48   gras_log_priority_uninitialized = -1 
49 } gras_log_priority_t;
50               
51
52 /**
53  * NLOG:
54  *
55  * All logging facilities are disabled at compilation time
56  */
57
58
59 /**
60  * GRAS_LOG_STATIC_THRESHOLD:
61  *
62  * All logging with priority < GRAS_LOG_STATIC_THRESHOLD is disabled at
63  * compile time, i.e., compiled out.
64  */
65 #ifdef NLOG
66 #  define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_infinite
67 #else
68
69 #  ifdef NDEBUG
70 #    define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_verbose
71 #  else /* !NLOG && !NDEBUG */
72
73 #    ifndef GRAS_LOG_STATIC_THRESHOLD
74 #      define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_none
75 #    endif /* !GRAS_LOG_STATIC_THRESHOLD */
76 #  endif /* NDEBUG */
77 #endif /* !defined(NLOG) */
78
79 /* Transforms a category name to a global variable name. */
80 #define _GRAS_LOGV(cat)   _GRAS_LOG_CONCAT(_gras_this_log_category_does_not_exist__, cat)
81 #define _GRAS_LOG_CONCAT(x,y) x ## y
82
83 /* The root of the category hierarchy. */
84 #define GRAS_LOG_ROOT_CAT   root
85
86 /**
87  * GRAS_LOG_NEW_SUBCATEGORY:
88  * @catName: name of new category
89  * @parent: father of the new category in the tree
90  *
91  * Defines a new subcategory of the parent. 
92  */
93 //#ifndef NLOG
94 #define GRAS_LOG_NEW_SUBCATEGORY(catName, parent)     \
95     extern gras_log_category_t _GRAS_LOGV(parent);    \
96     gras_log_category_t _GRAS_LOGV(catName) = {       \
97         &_GRAS_LOGV(parent), 0, 0,                    \
98         #catName, gras_log_priority_uninitialized, 1, \
99         0, 1                                          \
100     };
101 //#else /* No logging at all, please */
102 //#define GRAS_LOG_NEW_SUBCATEGORY(catName,parent)
103 //#endif
104
105 /**
106  * GRAS_LOG_NEW_CATEGORY:
107  * @catName: name of new category
108  *
109  * Creates a new subcategory of the root category.
110  */
111 #define GRAS_LOG_NEW_CATEGORY(catName)  GRAS_LOG_NEW_SUBCATEGORY(catName, GRAS_LOG_ROOT_CAT)
112
113 /**
114  * GRAS_LOG_DEFAULT_CATEGORY:
115  * @cname: name of the cat
116  *
117  * Indicates which category is the default one.
118  */
119
120 #if defined(GRAS_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
121 # define GRAS_LOG_DEFAULT_CATEGORY(cname)
122 #else
123 # define GRAS_LOG_DEFAULT_CATEGORY(cname) \
124          static gras_log_category_t* _GRAS_LOGV(default) = &_GRAS_LOGV(cname)
125 #endif
126
127 /**
128  * GRAS_LOG_NEW_DEFAULT_CATEGORY:
129  * @cname: name of the cat
130  *
131  * Creates a new subcategory of the root category and makes it the default
132  * (used by macros that don't explicitly specify a category).
133  */
134 #define GRAS_LOG_NEW_DEFAULT_CATEGORY(cname)        \
135     GRAS_LOG_NEW_CATEGORY(cname)                    \
136     GRAS_LOG_DEFAULT_CATEGORY(cname)
137
138 /**
139  * GRAS_LOG_NEW_DEFAULT_SUBCATEGORY:
140  * @cname: name of the cat
141  * @parent: name of the parent
142  *
143  * Creates a new subcategory of the parent category and makes it the default
144  * (used by macros that don't explicitly specify a category).
145  */
146 #define GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent)     \
147     GRAS_LOG_NEW_SUBCATEGORY(cname, parent)                 \
148     GRAS_LOG_DEFAULT_CATEGORY(cname)
149
150 /**
151  * GRAS_LOG_EXTERNAL_CATEGORY:
152  * @cname: name of the cat
153  *
154  * Indicates that a category you'll use in this file (to get subcategories of it, 
155  * for example) really lives in another file.
156  */
157
158 #define GRAS_LOG_EXTERNAL_CATEGORY(cname) \
159    extern gras_log_category_t _GRAS_LOGV(cname)
160
161 // Functions you may call
162
163 extern gras_error_t gras_log_control_set(const char* cs);
164
165 // Forward declarations
166 typedef struct gras_log_appender_s gras_log_appender_t;
167 typedef struct gras_log_event_s    gras_log_event_t;
168 typedef struct gras_log_category_s gras_log_category_t;
169
170 /**
171  * Do NOT access any members of this structure directly.
172  */
173 struct gras_log_category_s {
174             gras_log_category_t *parent;
175 /*@null@*/  gras_log_category_t *firstChild; 
176 /*@null@*/  gras_log_category_t *nextSibling;
177             const char *name;
178             int threshold;
179             int isThreshInherited;
180 /*@null@*/  gras_log_appender_t *appender;
181             int willLogToParent;
182   // TODO: Formats?
183 };
184
185 struct gras_log_appender_s {
186   void (*do_append) (gras_log_appender_t* thisLogAppender,
187                     gras_log_event_t* event, const char *fmt);
188   void *appender_data;
189 };
190
191 struct gras_log_event_s {
192   gras_log_category_t* cat;
193   gras_log_priority_t priority;
194   const char* fileName;
195   const char* functionName;
196   int lineNum;
197   va_list ap;
198 };
199
200 /**
201  * gras_log_threshold_set:
202  * @cat: the category (not only its name, but the variable)
203  * @thresholdPriority: the priority
204  *
205  * Programatically alters a category's threshold priority (don't use).
206  */
207 extern void gras_log_threshold_set(gras_log_category_t* cat,
208                                    gras_log_priority_t thresholdPriority);
209
210 /**
211  * gras_log_parent_set:
212  * @cat: the category (not only its name, but the variable)
213  * @parent: the parent cat
214  *
215  * Programatically alter a category's parent (don't use).
216  */
217 extern void gras_log_parent_set(gras_log_category_t* cat, 
218                                 gras_log_category_t* parent);
219
220 /**
221  * gras_log_appender_set:
222  * @cat: the category (not only its name, but the variable)
223  * @app: the appender
224  *
225  * Programatically sets the category's appender (don't use).
226  */
227 extern void gras_log_appender_set(gras_log_category_t* cat,
228                                   gras_log_appender_t* app);
229
230 // Functions that you shouldn't call. 
231 extern void _gras_log_event_log(gras_log_event_t*ev,
232                                 const char *fmt,
233                                 ...)
234 #ifdef __GNUC__
235      __attribute__ ((format (printf, 2, 3)))
236 #endif
237 ;
238
239 extern int _gras_log_cat_init(gras_log_priority_t priority, 
240                               gras_log_category_t* category);
241
242
243 extern gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT);
244 GRAS_LOG_EXTERNAL_CATEGORY(GRAS);
245 extern gras_log_appender_t *gras_log_default_appender;
246
247 /**
248  * GRAS_LOG_ISENABLED:
249  * @catName: name of the category
250  * @priority: minimal priority to be enabled to return true
251  *
252  * Returns true if the given priority is enabled for the category.
253  * If you have expensive expressions that are computed outside of the log
254  * command and used only within it, you should make its evaluation conditional
255  * using this macro.
256  */
257 #define GRAS_LOG_ISENABLED(catName, priority) \
258             _GRAS_LOG_ISENABLEDV(_GRAS_LOGV(catName), priority)
259
260 /*
261  * Helper function that implements GRAS_LOG_ISENABLED.
262  *
263  * NOTES
264  * First part is a compile-time constant.
265  * Call to _log_initCat only happens once.
266  */
267 #define _GRAS_LOG_ISENABLEDV(catv, priority)                  \
268        (priority >= GRAS_LOG_STATIC_THRESHOLD                 \
269         && priority >= catv.threshold                         \
270         && (catv.threshold != gras_log_priority_uninitialized \
271             || _gras_log_cat_init(priority, &catv)) )
272
273 /*
274  * Internal Macros
275  * Some kludge macros to ease maintenance. See how they're used below.
276  *
277  * IMPLEMENTATION NOTE: To reduce the parameter passing overhead of an enabled
278  * message, the many parameters passed to the logging function are packed in a
279  * structure. Since these values will be usually be passed to at least 3
280  * functions, this is a win.
281  * It also allows adding new values (such as a timestamp) without breaking
282  * code. 
283  * Setting the LogEvent's valist member is done inside _log_logEvent.
284  */
285
286 #define _GRAS_LOG_PRE(catv, priority) do {                              \
287      if (_GRAS_LOG_ISENABLEDV(catv, priority)) {                        \
288          gras_log_event_t _log_ev =                                     \
289              {&(catv),priority,__FILE__,__FUNCTION__,__LINE__};         \
290          _gras_log_event_log(&_log_ev
291
292 #define _GRAS_LOG_POST                          \
293                         );                      \
294      } } while(0)
295
296
297 /* Logging Macros */
298
299 #ifdef GRAS_LOG_MAYDAY
300 # define CLOG0(c, p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
301 # define CLOG1(c, p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
302 # define CLOG2(c, p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
303 # define CLOG3(c, p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
304 # define CLOG4(c, p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
305 # define CLOG5(c, p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
306 # 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)
307 # 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)
308 # 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)
309 #else
310 # define CLOG0(c, p, f)                   _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f _GRAS_LOG_POST                 
311 # define CLOG1(c, p, f,a1)                _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1 _GRAS_LOG_POST              
312 # define CLOG2(c, p, f,a1,a2)             _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2 _GRAS_LOG_POST
313 # define CLOG3(c, p, f,a1,a2,a3)          _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3 _GRAS_LOG_POST
314 # define CLOG4(c, p, f,a1,a2,a3,a4)       _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
315 # 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
316 # 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
317 # 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
318 # 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
319 #endif
320
321 #define CDEBUG0(c, f)                   CLOG0(c, gras_log_priority_debug, f)
322 #define CDEBUG1(c, f,a1)                CLOG1(c, gras_log_priority_debug, f,a1)
323 #define CDEBUG2(c, f,a1,a2)             CLOG2(c, gras_log_priority_debug, f,a1,a2)
324 #define CDEBUG3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_debug, f,a1,a2,a3)
325 #define CDEBUG4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_debug, f,a1,a2,a3,a4)
326 #define CDEBUG5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5)
327 #define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
328 #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)
329 #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)
330
331 #define CVERB0(c, f)                   CLOG0(c, gras_log_priority_verbose, f)
332 #define CVERB1(c, f,a1)                CLOG1(c, gras_log_priority_verbose, f,a1)
333 #define CVERB2(c, f,a1,a2)             CLOG2(c, gras_log_priority_verbose, f,a1,a2)
334 #define CVERB3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_verbose, f,a1,a2,a3)
335 #define CVERB4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_verbose, f,a1,a2,a3,a4)
336 #define CVERB5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
337 #define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
338
339 #define CINFO0(c, f)                   CLOG0(c, gras_log_priority_info, f)
340 #define CINFO1(c, f,a1)                CLOG1(c, gras_log_priority_info, f,a1)
341 #define CINFO2(c, f,a1,a2)             CLOG2(c, gras_log_priority_info, f,a1,a2)
342 #define CINFO3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_info, f,a1,a2,a3)
343 #define CINFO4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_info, f,a1,a2,a3,a4)
344 #define CINFO5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_info, f,a1,a2,a3,a4,a5)
345 #define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
346
347 #define CWARN0(c, f)                   CLOG0(c, gras_log_priority_warning, f)
348 #define CWARN1(c, f,a1)                CLOG1(c, gras_log_priority_warning, f,a1)
349 #define CWARN2(c, f,a1,a2)             CLOG2(c, gras_log_priority_warning, f,a1,a2)
350 #define CWARN3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_warning, f,a1,a2,a3)
351 #define CWARN4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_warning, f,a1,a2,a3,a4)
352 #define CWARN5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5)
353 #define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
354
355 #define CERROR0(c, f)                   CLOG0(c, gras_log_priority_error, f)
356 #define CERROR1(c, f,a1)                CLOG1(c, gras_log_priority_error, f,a1)
357 #define CERROR2(c, f,a1,a2)             CLOG2(c, gras_log_priority_error, f,a1,a2)
358 #define CERROR3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_error, f,a1,a2,a3)
359 #define CERROR4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_error, f,a1,a2,a3,a4)
360 #define CERROR5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_error, f,a1,a2,a3,a4,a5)
361 #define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
362
363 /**
364  * CCRITICAL6:
365  * @c: the category to log into
366  * @f: the format string
367  * @a1: first argument of the format
368  * @a2: second argument of the format
369  * @a3: third argument of the format
370  * @a4: fourth argument of the format
371  * @a5: fifth argument of the format
372  * @a6: sixth argument of the format
373  *
374  * Log something to the current default category under the warning priority.
375  *
376  * The macros CCRITICAL0 ... CCRITICAL5 naturally also exist, but are not listed here 
377  * for sake of clarity. They just differ in the number of arguments passed
378  * along with the format string.
379  */
380
381 #define CCRITICAL0(c, f)                   CLOG0(c, gras_log_priority_critical, f)
382 #define CCRITICAL1(c, f,a1)                CLOG1(c, gras_log_priority_critical, f,a1)
383 #define CCRITICAL2(c, f,a1,a2)             CLOG2(c, gras_log_priority_critical, f,a1,a2)
384 #define CCRITICAL3(c, f,a1,a2,a3)          CLOG3(c, gras_log_priority_critical, f,a1,a2,a3)
385 #define CCRITICAL4(c, f,a1,a2,a3,a4)       CLOG4(c, gras_log_priority_critical, f,a1,a2,a3,a4)
386 #define CCRITICAL5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5)
387 #define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
388
389 #ifdef GRAS_LOG_MAYDAY
390 # define LOG0(p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
391 # define LOG1(p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
392 # define LOG2(p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
393 # define LOG3(p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
394 # define LOG4(p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
395 # define LOG5(p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
396 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
397 # 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)
398 # 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)
399 #else
400 # define LOG0(p, f)                   _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f _GRAS_LOG_POST
401 # define LOG1(p, f,a1)                _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1 _GRAS_LOG_POST
402 # define LOG2(p, f,a1,a2)             _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2 _GRAS_LOG_POST
403 # define LOG3(p, f,a1,a2,a3)          _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3 _GRAS_LOG_POST
404 # define LOG4(p, f,a1,a2,a3,a4)       _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
405 # 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
406 # 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
407 # 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
408 # 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
409 #endif
410
411 /**
412  * DEBUG6:
413  * @f: the format string
414  * @a1: first argument of the format
415  * @a2: second argument of the format
416  * @a3: third argument of the format
417  * @a4: fourth argument of the format
418  * @a5: fifth argument of the format
419  * @a6: sixth argument of the format
420  *
421  * Log something to the current default category under the debug priority.
422  *
423  * The macros DEBUG0 ... DEBUG5 naturally also exist, but are not listed here 
424  * for sake of clarity. They just differ in the number of arguments passed
425  * along with the format string.
426  */
427
428 #define DEBUG0(f)                   LOG0(gras_log_priority_debug, f)
429 #define DEBUG1(f,a1)                LOG1(gras_log_priority_debug, f,a1)
430 #define DEBUG2(f,a1,a2)             LOG2(gras_log_priority_debug, f,a1,a2)
431 #define DEBUG3(f,a1,a2,a3)          LOG3(gras_log_priority_debug, f,a1,a2,a3)
432 #define DEBUG4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_debug, f,a1,a2,a3,a4)
433 #define DEBUG5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_debug, f,a1,a2,a3,a4,a5)
434 #define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
435 #define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
436 #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)
437
438 /**
439  * VERB6:
440  * @f: the format string
441  * @a1: first argument of the format
442  * @a2: second argument of the format
443  * @a3: third argument of the format
444  * @a4: fourth argument of the format
445  * @a5: fifth argument of the format
446  * @a6: sixth argument of the format
447  *
448  * Log something to the current default category under the verbose priority.
449  *
450  * The macros VERB0 ... VERB5 naturally also exist, but are not listed here 
451  * for sake of clarity. They just differ in the number of arguments passed
452  * along with the format string.
453  */
454
455 #define VERB0(f)                   LOG0(gras_log_priority_verbose, f)
456 #define VERB1(f,a1)                LOG1(gras_log_priority_verbose, f,a1)
457 #define VERB2(f,a1,a2)             LOG2(gras_log_priority_verbose, f,a1,a2)
458 #define VERB3(f,a1,a2,a3)          LOG3(gras_log_priority_verbose, f,a1,a2,a3)
459 #define VERB4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_verbose, f,a1,a2,a3,a4)
460 #define VERB5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
461 #define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
462
463 /**
464  * INFO6:
465  * @f: the format string
466  * @a1: first argument of the format
467  * @a2: second argument of the format
468  * @a3: third argument of the format
469  * @a4: fourth argument of the format
470  * @a5: fifth argument of the format
471  * @a6: sixth argument of the format
472  *
473  * Log something to the current default category under the info priority.
474  *
475  * The macros INFO0 ... INFO5 naturally also exist, but are not listed here 
476  * for sake of clarity. They just differ in the number of arguments passed
477  * along with the format string.
478  */
479
480 #define INFO0(f)                   LOG0(gras_log_priority_info, f)
481 #define INFO1(f,a1)                LOG1(gras_log_priority_info, f,a1)
482 #define INFO2(f,a1,a2)             LOG2(gras_log_priority_info, f,a1,a2)
483 #define INFO3(f,a1,a2,a3)          LOG3(gras_log_priority_info, f,a1,a2,a3)
484 #define INFO4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_info, f,a1,a2,a3,a4)
485 #define INFO5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_info, f,a1,a2,a3,a4,a5)
486 #define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
487
488 /**
489  * WARN6:
490  * @f: the format string
491  * @a1: first argument of the format
492  * @a2: second argument of the format
493  * @a3: third argument of the format
494  * @a4: fourth argument of the format
495  * @a5: fifth argument of the format
496  * @a6: sixth argument of the format
497  *
498  * Log something to the current default category under the warning priority.
499  *
500  * The macros WARN0 ... WARN5 naturally also exist, but are not listed here 
501  * for sake of clarity. They just differ in the number of arguments passed
502  * along with the format string.
503  */
504
505 #define WARN0(f)                   LOG0(gras_log_priority_warning, f)
506 #define WARN1(f,a1)                LOG1(gras_log_priority_warning, f,a1)
507 #define WARN2(f,a1,a2)             LOG2(gras_log_priority_warning, f,a1,a2)
508 #define WARN3(f,a1,a2,a3)          LOG3(gras_log_priority_warning, f,a1,a2,a3)
509 #define WARN4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_warning, f,a1,a2,a3,a4)
510 #define WARN5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_warning, f,a1,a2,a3,a4,a5)
511 #define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
512
513 /**
514  * ERROR6:
515  * @f: the format string
516  * @a1: first argument of the format
517  * @a2: second argument of the format
518  * @a3: third argument of the format
519  * @a4: fourth argument of the format
520  * @a5: fifth argument of the format
521  * @a6: sixth argument of the format
522  *
523  * Log something to the current default category under the error priority.
524  *
525  * The macros ERROR0 ... ERROR5 naturally also exist, but are not listed here 
526  * for sake of clarity. They just differ in the number of arguments passed
527  * along with the format string.
528  */
529
530 #define ERROR0(f)                   LOG0(gras_log_priority_error, f)
531 #define ERROR1(f,a1)                LOG1(gras_log_priority_error, f,a1)
532 #define ERROR2(f,a1,a2)             LOG2(gras_log_priority_error, f,a1,a2)
533 #define ERROR3(f,a1,a2,a3)          LOG3(gras_log_priority_error, f,a1,a2,a3)
534 #define ERROR4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_error, f,a1,a2,a3,a4)
535 #define ERROR5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_error, f,a1,a2,a3,a4,a5)
536 #define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
537
538 /**
539  * CRITICAL6:
540  * @f: the format string
541  * @a1: first argument of the format
542  * @a2: second argument of the format
543  * @a3: third argument of the format
544  * @a4: fourth argument of the format
545  * @a5: fifth argument of the format
546  * @a6: sixth argument of the format
547  *
548  * Log something to the current default category under the critical priority.
549  *
550  * The macros CRITICAL0 ... CRITICAL5 naturally also exist, but are not listed here 
551  * for sake of clarity. They just differ in the number of arguments passed
552  * along with the format string.
553  */
554 #define CRITICAL0(f)                   LOG0(gras_log_priority_critical, f)
555 #define CRITICAL1(f,a1)                LOG1(gras_log_priority_critical, f,a1)
556 #define CRITICAL2(f,a1,a2)             LOG2(gras_log_priority_critical, f,a1,a2)
557 #define CRITICAL3(f,a1,a2,a3)          LOG3(gras_log_priority_critical, f,a1,a2,a3)
558 #define CRITICAL4(f,a1,a2,a3,a4)       LOG4(gras_log_priority_critical, f,a1,a2,a3,a4)
559 #define CRITICAL5(f,a1,a2,a3,a4,a5)    LOG5(gras_log_priority_critical, f,a1,a2,a3,a4,a5)
560 #define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
561
562 #ifdef __GNUC__
563 #define GRAS_IN               LOG1(gras_log_priority_trace, ">> begin of %s",     __FUNCTION__)
564 #define GRAS_IN1(fmt,a)       LOG2(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a)
565 #define GRAS_IN2(fmt,a,b)     LOG3(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b)
566 #define GRAS_IN3(fmt,a,b,c)   LOG4(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b,c)
567 #define GRAS_IN4(fmt,a,b,c,d) LOG5(gras_log_priority_trace, ">> begin of %s" fmt, __FUNCTION__, a,b,c,d)
568 #define GRAS_OUT              LOG1(gras_log_priority_trace, "<< end of %s",       __FUNCTION__)
569 #else /* if fool enough to compile without gcc */
570 #define GRAS_IN               LOG0(gras_log_priority_trace, ">> begin of function")
571 #define GRAS_IN1(fmt,a)       LOG2(gras_log_priority_trace, ">> begin of function " fmt, a)
572 #define GRAS_IN2(fmt,a,b)     LOG3(gras_log_priority_trace, ">> begin of function " fmt, a,b)
573 #define GRAS_IN3(fmt,a,b,c)   LOG4(gras_log_priority_trace, ">> begin of function " fmt, a,b,c)
574 #define GRAS_IN4(fmt,a,b,c,d) LOG5(gras_log_priority_trace, ">> begin of function " fmt, a,b,c,d)
575
576 #define GRAS_OUT(fmt,a) LOG0(gras_log_priority_trace, "<< end of function")
577 #endif /* end of foolness for non-gcc */
578
579 #endif /* ! _GRAS_LOG_H_ */