Logo AND Algorithmique Numérique Distribuée

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