Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
XBT documentation reorganization. module-xbt only contains the structure, module...
[simgrid.git] / include / xbt / log.h
1 /* $Id$ */
2
3 /* log - a generic logging facility in the spirit of log4j                  */
4
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 /** @addtogroup XBT_log
11  *  @brief A generic logging facility in the spirit of log4j (grounding feature)
12  *
13  * <center><table><tr><td><b>Top</b>    <td> [\ref index]::[\ref XBT_API]
14  *                <tr><td><b>Prev</b>   <td> [\ref XBT_ex]
15  *                <tr><td><b>Next</b>   <td> [\ref XBT_error]     
16  *                <tr><td><b>Down</b>   <td> [\ref XBT_log_cats]        </table></center>
17  *
18  */
19  
20 /** \defgroup XBT_log_cats Existing log categories
21  *  \ingroup XBT_log
22  *  \brief (automatically extracted) 
23  *     
24  * <center><table><tr><td><b>Top</b>    <td> [\ref index]::[\ref XBT_API]::[\ref XBT_log] </table></center>
25  *
26  *  This is the list of all existing log categories in SimGrid.
27  *  This list was automatically extracted from the source code by
28  *  the src/xbt_log_extract_hierarchy utility.
29  *     
30  *  You can thus be certain that it is uptodate, but it may somehow
31  *  lack a final manual touch.
32  *  Anyway, nothing's perfect ;)
33  */
34
35 /* XBT_LOG_MAYDAY: define this to replace the logging facilities with basic
36    printf function. Useful to debug the logging facilities themselves */
37 #undef XBT_LOG_MAYDAY
38 /*#define XBT_LOG_MAYDAY*/
39
40 #ifndef _XBT_LOG_H_
41 #define _XBT_LOG_H_
42
43 #include "xbt/misc.h"
44
45 #include <stdarg.h>
46
47 /**\brief Log priorities
48  * \ingroup XBT_log
49  *
50  * The different existing priorities.
51 */
52 typedef enum {
53   xbt_log_priority_none          = 0,  /* used internally (don't poke with) */
54   xbt_log_priority_trace         = 1,  /**< enter and return of some functions */
55   xbt_log_priority_debug         = 2,  /**< crufty output  */
56   xbt_log_priority_verbose       = 3,  /**< verbose output for the user wanting more */
57   xbt_log_priority_info          = 4,  /**< output about the regular functionning */
58   xbt_log_priority_warning       = 5,  /**< minor issue encountered */
59   xbt_log_priority_error         = 6,  /**< issue encountered */
60   xbt_log_priority_critical      = 7,  /**< major issue encountered */
61
62   xbt_log_priority_infinite      = 8,  /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
63
64   xbt_log_priority_uninitialized = -1  /* used internally (don't poke with) */
65 } e_xbt_log_priority_t;
66               
67
68 /*
69  * define NLOG to disable at compilation time any logging request
70  * define NDEBUG to disable at compilation time any logging request of priority below INFO
71  */
72
73
74 /**
75  * @def XBT_LOG_STATIC_THRESHOLD
76  * @ingroup XBT_log
77  *
78  * All logging requests with priority < XBT_LOG_STATIC_THRESHOLD are disabled at
79  * compile time, i.e., compiled out.
80  */
81 #ifdef NLOG
82 #  define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_infinite
83 #else
84
85 #  ifdef NDEBUG
86 #    define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_verbose
87 #  else /* !NLOG && !NDEBUG */
88
89 #    ifndef XBT_LOG_STATIC_THRESHOLD
90 #      define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_none
91 #    endif /* !XBT_LOG_STATIC_THRESHOLD */
92 #  endif /* NDEBUG */
93 #endif /* !defined(NLOG) */
94
95 /* Transforms a category name to a global variable name. */
96 #define _XBT_LOGV(cat)   _XBT_LOG_CONCAT(_gras_this_log_category_does_not_exist__, cat)
97 #define _XBT_LOG_CONCAT(x,y) x ## y
98
99 /* The root of the category hierarchy. */
100 #define XBT_LOG_ROOT_CAT   root
101
102 /* XBT_LOG_NEW_SUBCATEGORY_helper:
103  * Implementation of XBT_LOG_NEW_SUBCATEGORY, which must declare "extern parent" in addition
104  * to avoid an extra declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by
105  * XBT_LOG_NEW_CATEGORY */
106 #define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
107     s_xbt_log_category_t _XBT_LOGV(catName) = {       \
108         &_XBT_LOGV(parent), 0, 0,                    \
109         #catName, xbt_log_priority_uninitialized, 1, \
110         0, 1                                          \
111     }
112 /**
113  * \ingroup XBT_log
114  * \param catName name of new category
115  * \param parent father of the new category in the tree
116  * \param desc string describing the purpose of this category
117  * \hideinitializer
118  *
119  * Defines a new subcategory of the parent. 
120  */
121 #define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc)    \
122     extern s_xbt_log_category_t _XBT_LOGV(parent);        \
123     XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
124
125 /**
126  * \ingroup XBT_log  
127  * \param catName name of new category
128  * \param desc string describing the purpose of this category
129  * \hideinitializer
130  *
131  * Creates a new subcategory of the root category.
132  */
133 #define XBT_LOG_NEW_CATEGORY(catName,desc)  XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc)
134
135 /**
136  * \ingroup XBT_log  
137  * \param cname name of the cat
138  * \hideinitializer
139  *
140  * Indicates which category is the default one.
141  */
142
143 #if defined(XBT_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
144 # define XBT_LOG_DEFAULT_CATEGORY(cname)
145 #else
146 # define XBT_LOG_DEFAULT_CATEGORY(cname) \
147          static xbt_log_category_t _XBT_LOGV(default) = &_XBT_LOGV(cname)
148 #endif
149
150 /**
151  * \ingroup XBT_log  
152  * \param cname name of the cat
153  * \param desc string describing the purpose of this category
154  * \hideinitializer
155  *
156  * Creates a new subcategory of the root category and makes it the default
157  * (used by macros that don't explicitly specify a category).
158  */
159 #define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc)        \
160     XBT_LOG_NEW_CATEGORY(cname,desc);                   \
161     XBT_LOG_DEFAULT_CATEGORY(cname)
162
163 /**
164  * \ingroup XBT_log  
165  * \param cname name of the cat
166  * \param parent name of the parent
167  * \param desc string describing the purpose of this category
168  * \hideinitializer
169  *
170  * Creates a new subcategory of the parent category and makes it the default
171  * (used by macros that don't explicitly specify a category).
172  */
173 #define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
174     XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc);            \
175     XBT_LOG_DEFAULT_CATEGORY(cname)
176
177 /**
178  * \ingroup XBT_log  
179  * \param cname name of the cat
180  * \hideinitializer
181  *
182  * Indicates that a category you'll use in this file (to get subcategories of it, 
183  * for example) really lives in another file.
184  */
185
186 #define XBT_LOG_EXTERNAL_CATEGORY(cname) \
187    extern s_xbt_log_category_t _XBT_LOGV(cname)
188
189 /* Functions you may call */
190
191 extern void xbt_log_control_set(const char* cs);
192
193 /* Forward declarations */
194 typedef struct xbt_log_appender_s s_xbt_log_appender_t,*xbt_log_appender_t;
195 typedef struct xbt_log_event_s    s_xbt_log_event_t,   *xbt_log_event_t;
196 typedef struct xbt_log_category_s s_xbt_log_category_t,*xbt_log_category_t;
197
198 /*
199  * Do NOT access any members of this structure directly. FIXME: move to private?
200  */
201 struct xbt_log_category_s {
202             xbt_log_category_t parent;
203 /*@null@*/  xbt_log_category_t firstChild; 
204 /*@null@*/  xbt_log_category_t nextSibling;
205             const char *name;
206             int threshold;
207             int isThreshInherited;
208 /*@null@*/  xbt_log_appender_t appender;
209             int willLogToParent;
210   /* TODO: Formats? */
211 };
212
213 struct xbt_log_appender_s {
214   void (*do_append) (xbt_log_appender_t thisLogAppender,
215                     xbt_log_event_t event, const char *fmt);
216   void *appender_data;
217 };
218
219 struct xbt_log_event_s {
220   xbt_log_category_t cat;
221   e_xbt_log_priority_t priority;
222   const char* fileName;
223   const char* functionName;
224   int lineNum;
225   va_list ap;
226 };
227
228 /**
229  * \ingroup XBT_log_implem
230  * \param cat the category (not only its name, but the variable)
231  * \param thresholdPriority the priority
232  *
233  * Programatically alters a category's threshold priority (don't use).
234  */
235 extern void xbt_log_threshold_set(xbt_log_category_t cat,
236                                    e_xbt_log_priority_t thresholdPriority);
237
238 /**
239  * \ingroup XBT_log_implem  
240  * \param cat the category (not only its name, but the variable)
241  * \param parent the parent cat
242  *
243  * Programatically alter a category's parent (don't use).
244  */
245 extern void xbt_log_parent_set(xbt_log_category_t cat,
246                                 xbt_log_category_t parent);
247
248 /**
249  * \ingroup XBT_log_implem  
250  * \param cat the category (not only its name, but the variable)
251  * \param app the appender
252  *
253  * Programatically sets the category's appender (don't use).
254  */
255 extern void xbt_log_appender_set(xbt_log_category_t cat,
256                                   xbt_log_appender_t app);
257
258 /* Functions that you shouldn't call. */
259 extern void _xbt_log_event_log(xbt_log_event_t ev,
260                                 const char *fmt,
261                                 ...) _XBT_GNUC_PRINTF(2,3);
262
263 extern int _xbt_log_cat_init(e_xbt_log_priority_t priority, 
264                               xbt_log_category_t   category);
265
266
267 extern s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT);
268 XBT_LOG_EXTERNAL_CATEGORY(GRAS);
269 extern xbt_log_appender_t xbt_log_default_appender;
270
271 /**
272  * \ingroup XBT_log 
273  * \param catName name of the category
274  * \param priority minimal priority to be enabled to return true
275  * \hideinitializer
276  *
277  * Returns true if the given priority is enabled for the category.
278  * If you have expensive expressions that are computed outside of the log
279  * command and used only within it, you should make its evaluation conditional
280  * using this macro.
281  */
282 #define XBT_LOG_ISENABLED(catName, priority) \
283             _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
284
285 /*
286  * Helper function that implements XBT_LOG_ISENABLED.
287  *
288  * NOTES
289  * First part is a compile-time constant.
290  * Call to _log_initCat only happens once.
291  */
292 #define _XBT_LOG_ISENABLEDV(catv, priority)                  \
293        (priority >= XBT_LOG_STATIC_THRESHOLD                 \
294         && priority >= catv.threshold                         \
295         && (catv.threshold != xbt_log_priority_uninitialized \
296             || _xbt_log_cat_init(priority, &catv)) )
297
298 /*
299  * Internal Macros
300  * Some kludge macros to ease maintenance. See how they're used below.
301  *
302  * IMPLEMENTATION NOTE: To reduce the parameter passing overhead of an enabled
303  * message, the many parameters passed to the logging function are packed in a
304  * structure. Since these values will be usually be passed to at least 3
305  * functions, this is a win.
306  * It also allows adding new values (such as a timestamp) without breaking
307  * code. 
308  * Setting the LogEvent's valist member is done inside _log_logEvent.
309  */
310
311 #define _XBT_LOG_PRE(catv, priority) do {                              \
312      if (_XBT_LOG_ISENABLEDV(catv, priority)) {                        \
313          s_xbt_log_event_t _log_ev =                                   \
314              {&(catv),priority,__FILE__,_XBT_FUNCTION,__LINE__};         \
315          _xbt_log_event_log(&_log_ev
316
317 #define _XBT_LOG_POST                          \
318                         );                      \
319      } } while(0)
320
321
322 /* Logging Macros */
323
324 #ifdef XBT_LOG_MAYDAY
325 # define CLOG0(c, p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
326 # define CLOG1(c, p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
327 # define CLOG2(c, p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
328 # define CLOG3(c, p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
329 # define CLOG4(c, p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
330 # define CLOG5(c, p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
331 # 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)
332 # 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)
333 # 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)
334 #else
335 # define CLOG0(c, p, f)                   _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f _XBT_LOG_POST            
336 # define CLOG1(c, p, f,a1)                _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1 _XBT_LOG_POST                 
337 # define CLOG2(c, p, f,a1,a2)             _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2 _XBT_LOG_POST
338 # define CLOG3(c, p, f,a1,a2,a3)          _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3 _XBT_LOG_POST
339 # define CLOG4(c, p, f,a1,a2,a3,a4)       _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
340 # define CLOG5(c, p, f,a1,a2,a3,a4,a5)    _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5 _XBT_LOG_POST
341 # define CLOG6(c, p, f,a1,a2,a3,a4,a5,a6) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6 _XBT_LOG_POST
342 # define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7 _XBT_LOG_POST
343 # define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _XBT_LOG_POST
344 #endif
345
346 #define CDEBUG0(c, f)                   CLOG0(c, xbt_log_priority_debug, f)
347 #define CDEBUG1(c, f,a1)                CLOG1(c, xbt_log_priority_debug, f,a1)
348 #define CDEBUG2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_debug, f,a1,a2)
349 #define CDEBUG3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_debug, f,a1,a2,a3)
350 #define CDEBUG4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_debug, f,a1,a2,a3,a4)
351 #define CDEBUG5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
352 #define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
353 #define CDEBUG7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
354 #define CDEBUG8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
355
356 #define CVERB0(c, f)                   CLOG0(c, xbt_log_priority_verbose, f)
357 #define CVERB1(c, f,a1)                CLOG1(c, xbt_log_priority_verbose, f,a1)
358 #define CVERB2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_verbose, f,a1,a2)
359 #define CVERB3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_verbose, f,a1,a2,a3)
360 #define CVERB4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_verbose, f,a1,a2,a3,a4)
361 #define CVERB5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
362 #define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
363
364 #define CINFO0(c, f)                   CLOG0(c, xbt_log_priority_info, f)
365 #define CINFO1(c, f,a1)                CLOG1(c, xbt_log_priority_info, f,a1)
366 #define CINFO2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_info, f,a1,a2)
367 #define CINFO3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_info, f,a1,a2,a3)
368 #define CINFO4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_info, f,a1,a2,a3,a4)
369 #define CINFO5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5)
370 #define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
371
372 #define CWARN0(c, f)                   CLOG0(c, xbt_log_priority_warning, f)
373 #define CWARN1(c, f,a1)                CLOG1(c, xbt_log_priority_warning, f,a1)
374 #define CWARN2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_warning, f,a1,a2)
375 #define CWARN3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_warning, f,a1,a2,a3)
376 #define CWARN4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_warning, f,a1,a2,a3,a4)
377 #define CWARN5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
378 #define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
379
380 #define CERROR0(c, f)                   CLOG0(c, xbt_log_priority_error, f)
381 #define CERROR1(c, f,a1)                CLOG1(c, xbt_log_priority_error, f,a1)
382 #define CERROR2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_error, f,a1,a2)
383 #define CERROR3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_error, f,a1,a2,a3)
384 #define CERROR4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_error, f,a1,a2,a3,a4)
385 #define CERROR5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5)
386 #define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
387
388 #define CCRITICAL0(c, f)                   CLOG0(c, xbt_log_priority_critical, f)
389 #define CCRITICAL1(c, f,a1)                CLOG1(c, xbt_log_priority_critical, f,a1)
390 #define CCRITICAL2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_critical, f,a1,a2)
391 #define CCRITICAL3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_critical, f,a1,a2,a3)
392 #define CCRITICAL4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_critical, f,a1,a2,a3,a4)
393 #define CCRITICAL5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
394 #define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
395
396 #ifdef XBT_LOG_MAYDAY
397 # define LOG0(p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
398 # define LOG1(p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
399 # define LOG2(p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
400 # define LOG3(p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
401 # define LOG4(p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
402 # define LOG5(p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
403 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
404 # 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)
405 # 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)
406 #else
407 # define LOG0(p, f)                   _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f _XBT_LOG_POST
408 # define LOG1(p, f,a1)                _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1 _XBT_LOG_POST
409 # define LOG2(p, f,a1,a2)             _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2 _XBT_LOG_POST
410 # define LOG3(p, f,a1,a2,a3)          _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3 _XBT_LOG_POST
411 # define LOG4(p, f,a1,a2,a3,a4)       _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
412 # define LOG5(p, f,a1,a2,a3,a4,a5)    _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5 _XBT_LOG_POST
413 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6 _XBT_LOG_POST
414 # define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7 _XBT_LOG_POST
415 # define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _XBT_LOG_POST
416 #endif
417
418 /** \name DEBUG
419  * \ingroup XBT_log
420  * Log something to the current default category under the debug priority.
421  * \param f the format string
422  * \param a1 first argument of the format
423  * \param a2 second argument of the format
424  * \param a3 third argument of the format
425  * \param a4 fourth argument of the format
426  * \param a5 fifth argument of the format
427  * \param a6 sixth argument of the format
428  *
429  * The macros DEBUG0 ... DEBUG5 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 DEBUG0(f)                   LOG0(xbt_log_priority_debug, f)
435 #define DEBUG1(f,a1)                LOG1(xbt_log_priority_debug, f,a1)
436 #define DEBUG2(f,a1,a2)             LOG2(xbt_log_priority_debug, f,a1,a2)
437 #define DEBUG3(f,a1,a2,a3)          LOG3(xbt_log_priority_debug, f,a1,a2,a3)
438 #define DEBUG4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_debug, f,a1,a2,a3,a4)
439 #define DEBUG5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
440 #define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
441 #define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
442 #define DEBUG8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
443 /* @} */
444
445 /** \name VERB
446  * \ingroup XBT_log
447  * Log something to the current default category under the verbose priority.
448  * \param f the format string
449  * \param a1 first argument of the format
450  * \param a2 second argument of the format
451  * \param a3 third argument of the format
452  * \param a4 fourth argument of the format
453  * \param a5 fifth argument of the format
454  * \param a6 sixth argument of the format
455  *
456  * The macros VERB0 ... VERB5 naturally also exist, but are not listed here 
457  * for sake of clarity. They just differ in the number of arguments passed
458  * along with the format string.
459  */
460 /* @{ */
461 #define VERB0(f)                   LOG0(xbt_log_priority_verbose, f)
462 #define VERB1(f,a1)                LOG1(xbt_log_priority_verbose, f,a1)
463 #define VERB2(f,a1,a2)             LOG2(xbt_log_priority_verbose, f,a1,a2)
464 #define VERB3(f,a1,a2,a3)          LOG3(xbt_log_priority_verbose, f,a1,a2,a3)
465 #define VERB4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_verbose, f,a1,a2,a3,a4)
466 #define VERB5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
467 #define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
468 /* @} */
469
470 /** \name INFO
471  * \ingroup XBT_log
472  * Log something to the current default category under the info priority.
473  * \param f the format string
474  * \param a1 first argument of the format
475  * \param a2 second argument of the format
476  * \param a3 third argument of the format
477  * \param a4 fourth argument of the format
478  * \param a5 fifth argument of the format
479  * \param a6 sixth argument of the format
480  *
481  * The macros INFO0 ... INFO5 naturally also exist, but are not listed here 
482  * for sake of clarity. They just differ in the number of arguments passed
483  * along with the format string.
484  */
485 /* @{ */
486 #define INFO0(f)                   LOG0(xbt_log_priority_info, f)
487 #define INFO1(f,a1)                LOG1(xbt_log_priority_info, f,a1)
488 #define INFO2(f,a1,a2)             LOG2(xbt_log_priority_info, f,a1,a2)
489 #define INFO3(f,a1,a2,a3)          LOG3(xbt_log_priority_info, f,a1,a2,a3)
490 #define INFO4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_info, f,a1,a2,a3,a4)
491 #define INFO5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_info, f,a1,a2,a3,a4,a5)
492 #define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
493 /* @} */
494
495 /** \name WARN
496  * \ingroup XBT_log
497  * Log something to the current default category under the warning priority.
498  * \param f the format string
499  * \param a1 first argument of the format
500  * \param a2 second argument of the format
501  * \param a3 third argument of the format
502  * \param a4 fourth argument of the format
503  * \param a5 fifth argument of the format
504  * \param a6 sixth argument of the format
505  *
506  * The macros WARN0 ... WARN5 naturally also exist, but are not listed here 
507  * for sake of clarity. They just differ in the number of arguments passed
508  * along with the format string.
509  */
510 /* @{ */
511 #define WARN0(f)                   LOG0(xbt_log_priority_warning, f)
512 #define WARN1(f,a1)                LOG1(xbt_log_priority_warning, f,a1)
513 #define WARN2(f,a1,a2)             LOG2(xbt_log_priority_warning, f,a1,a2)
514 #define WARN3(f,a1,a2,a3)          LOG3(xbt_log_priority_warning, f,a1,a2,a3)
515 #define WARN4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_warning, f,a1,a2,a3,a4)
516 #define WARN5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
517 #define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
518 /* @} */
519
520 /** \name ERROR
521  * \ingroup XBT_log
522  * Log something to the current default category under the error priority.
523  * \param f the format string
524  * \param a1 first argument of the format
525  * \param a2 second argument of the format
526  * \param a3 third argument of the format
527  * \param a4 fourth argument of the format
528  * \param a5 fifth argument of the format
529  * \param a6 sixth argument of the format
530  *
531  * The macros ERROR0 ... ERROR5 naturally also exist, but are not listed here 
532  * for sake of clarity. They just differ in the number of arguments passed
533  * along with the format string.
534  */
535 /* @{ */
536 #define ERROR0(f)                   LOG0(xbt_log_priority_error, f)
537 #define ERROR1(f,a1)                LOG1(xbt_log_priority_error, f,a1)
538 #define ERROR2(f,a1,a2)             LOG2(xbt_log_priority_error, f,a1,a2)
539 #define ERROR3(f,a1,a2,a3)          LOG3(xbt_log_priority_error, f,a1,a2,a3)
540 #define ERROR4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_error, f,a1,a2,a3,a4)
541 #define ERROR5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_error, f,a1,a2,a3,a4,a5)
542 #define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
543 /* @} */
544
545 /** \name CRITICAL
546  * \ingroup XBT_log
547  * Log something to the current default category under the critical priority.
548  * \param f the format string
549  * \param a1 first argument of the format
550  * \param a2 second argument of the format
551  * \param a3 third argument of the format
552  * \param a4 fourth argument of the format
553  * \param a5 fifth argument of the format
554  * \param a6 sixth argument of the format
555  *
556  * The macros CRITICAL0 ... CRITICAL5 naturally also exist, but are not listed here 
557  * for sake of clarity. They just differ in the number of arguments passed
558  * along with the format string.
559  */
560 /* @{ */
561 #define CRITICAL0(f)                   LOG0(xbt_log_priority_critical, f)
562 #define CRITICAL1(f,a1)                LOG1(xbt_log_priority_critical, f,a1)
563 #define CRITICAL2(f,a1,a2)             LOG2(xbt_log_priority_critical, f,a1,a2)
564 #define CRITICAL3(f,a1,a2,a3)          LOG3(xbt_log_priority_critical, f,a1,a2,a3)
565 #define CRITICAL4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_critical, f,a1,a2,a3,a4)
566 #define CRITICAL5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
567 #define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
568 /* @} */
569
570 #define XBT_IN               LOG1(xbt_log_priority_trace, ">> begin of %s",     _XBT_FUNCTION)
571 #define XBT_IN1(fmt,a)       LOG2(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a)
572 #define XBT_IN2(fmt,a,b)     LOG3(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b)
573 #define XBT_IN3(fmt,a,b,c)   LOG4(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c)
574 #define XBT_IN4(fmt,a,b,c,d) LOG5(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c,d)
575 #define XBT_OUT              LOG1(xbt_log_priority_trace, "<< end of %s",       _XBT_FUNCTION)
576 #define XBT_HERE             LOG0(xbt_log_priority_trace, "-- was here")
577
578 #endif /* ! _XBT_LOG_H_ */