Logo AND Algorithmique Numérique Distribuée

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