Logo AND Algorithmique Numérique Distribuée

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