Logo AND Algorithmique Numérique Distribuée

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