Logo AND Algorithmique Numérique Distribuée

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