Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
26efd1358ba4330dd0d6ffe3432a854395cd1851
[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_PUBLIC_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 #define XBT_LOG_NEW_CATEGORY(catName,desc)  XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc)
128
129 /**
130  * \ingroup XBT_log  
131  * \param cname name of the cat
132  * \hideinitializer
133  *
134  * Indicates which category is the default one.
135  */
136
137 #if defined(XBT_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
138 # define XBT_LOG_DEFAULT_CATEGORY(cname)
139 #else
140 # define XBT_LOG_DEFAULT_CATEGORY(cname) \
141          static xbt_log_category_t _XBT_LOGV(default) _XBT_GNUC_UNUSED = &_XBT_LOGV(cname) 
142 #endif
143
144 /**
145  * \ingroup XBT_log  
146  * \param cname name of the cat
147  * \param desc string describing the purpose of this category
148  * \hideinitializer
149  *
150  * Creates a new subcategory of the root category and makes it the default
151  * (used by macros that don't explicitly specify a category).
152  */
153 #define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc)        \
154     XBT_LOG_NEW_CATEGORY(cname,desc);                   \
155     XBT_LOG_DEFAULT_CATEGORY(cname)
156
157 /**
158  * \ingroup XBT_log  
159  * \param cname name of the cat
160  * \param parent name of the parent
161  * \param desc string describing the purpose of this category
162  * \hideinitializer
163  *
164  * Creates a new subcategory of the parent category and makes it the default
165  * (used by macros that don't explicitly specify a category).
166  */
167 #define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
168     XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc);            \
169     XBT_LOG_DEFAULT_CATEGORY(cname)
170
171 /**
172  * \ingroup XBT_log  
173  * \param cname name of the cat
174  * \hideinitializer
175  *
176  * Indicates that a category you'll use in this file (to get subcategories of it, 
177  * for example) really lives in another file.
178  */
179
180 #define XBT_LOG_EXTERNAL_CATEGORY(cname) \
181    extern s_xbt_log_category_t _XBT_LOGV(cname)
182
183 /**
184  * \ingroup XBT_log
185  * \param cname name of the cat
186  * \hideinitializer
187  *
188  * Indicates that the default category of this file was declared in another file.
189  */
190
191 #define XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(cname) \
192    XBT_LOG_EXTERNAL_CATEGORY(cname);\
193    XBT_LOG_DEFAULT_CATEGORY(cname)
194
195 /* Functions you may call */
196
197 XBT_PUBLIC(void) xbt_log_control_set(const char* cs);
198
199 /* Forward declarations */
200 typedef struct xbt_log_appender_s s_xbt_log_appender_t,*xbt_log_appender_t;
201 typedef struct xbt_log_event_s    s_xbt_log_event_t,   *xbt_log_event_t;
202 typedef struct xbt_log_category_s s_xbt_log_category_t,*xbt_log_category_t;
203
204 /*
205  * Do NOT access any members of this structure directly. FIXME: move to private?
206  */
207 struct xbt_log_category_s {
208             xbt_log_category_t parent;
209 /*@null@*/  xbt_log_category_t firstChild; 
210 /*@null@*/  xbt_log_category_t nextSibling;
211             const char *name;
212             int threshold;
213             int isThreshInherited;
214 /*@null@*/  xbt_log_appender_t appender;
215             int willLogToParent;
216   /* TODO: Formats? */
217 };
218
219 struct xbt_log_appender_s {
220   void (*do_append) (xbt_log_appender_t thisLogAppender,
221                     xbt_log_event_t event, const char *fmt);
222   void *appender_data;
223 };
224
225 struct xbt_log_event_s {
226   xbt_log_category_t cat;
227   e_xbt_log_priority_t priority;
228   const char* fileName;
229   const char* functionName;
230   int lineNum;
231   va_list ap;
232 };
233
234 /**
235  * \ingroup XBT_log_implem
236  * \param cat the category (not only its name, but the variable)
237  * \param thresholdPriority the priority
238  *
239  * Programatically alters a category's threshold priority (don't use).
240  */
241 XBT_PUBLIC(void) xbt_log_threshold_set(xbt_log_category_t cat,
242                                    e_xbt_log_priority_t thresholdPriority);
243
244 /**
245  * \ingroup XBT_log_implem  
246  * \param cat the category (not only its name, but the variable)
247  * \param parent the parent cat
248  *
249  * Programatically alter a category's parent (don't use).
250  */
251 XBT_PUBLIC(void) xbt_log_parent_set(xbt_log_category_t cat,
252                                 xbt_log_category_t parent);
253
254 /**
255  * \ingroup XBT_log_implem  
256  * \param cat the category (not only its name, but the variable)
257  * \param app the appender
258  *
259  * Programatically sets the category's appender (don't use).
260  */
261 XBT_PUBLIC(void) xbt_log_appender_set(xbt_log_category_t cat,
262                                   xbt_log_appender_t app);
263
264 /* Functions that you shouldn't call. */
265 XBT_PUBLIC(void) _xbt_log_event_log(xbt_log_event_t ev,
266                                 const char *fmt,
267                                 ...) _XBT_GNUC_PRINTF(2,3);
268
269 XBT_PUBLIC(int) _xbt_log_cat_init(e_xbt_log_priority_t priority, 
270                               xbt_log_category_t   category);
271
272
273 extern s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT);
274 XBT_LOG_EXTERNAL_CATEGORY(GRAS);
275 extern xbt_log_appender_t xbt_log_default_appender;
276
277 /**
278  * \ingroup XBT_log 
279  * \param catName name of the category
280  * \param priority minimal priority to be enabled to return true
281  * \hideinitializer
282  *
283  * Returns true if the given priority is enabled for the category.
284  * If you have expensive expressions that are computed outside of the log
285  * command and used only within it, you should make its evaluation conditional
286  * using this macro.
287  */
288 #define XBT_LOG_ISENABLED(catName, priority) \
289             _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
290
291 /*
292  * Helper function that implements XBT_LOG_ISENABLED.
293  *
294  * NOTES
295  * First part is a compile-time constant.
296  * Call to _log_initCat only happens once.
297  */
298 #define _XBT_LOG_ISENABLEDV(catv, priority)                  \
299        (priority >= XBT_LOG_STATIC_THRESHOLD                 \
300         && priority >= catv.threshold                         \
301         && (catv.threshold != xbt_log_priority_uninitialized \
302             || _xbt_log_cat_init(priority, &catv)) )
303
304 /*
305  * Internal Macros
306  * Some kludge macros to ease maintenance. See how they're used below.
307  *
308  * IMPLEMENTATION NOTE: To reduce the parameter passing overhead of an enabled
309  * message, the many parameters passed to the logging function are packed in a
310  * structure. Since these values will be usually be passed to at least 3
311  * functions, this is a win.
312  * It also allows adding new values (such as a timestamp) without breaking
313  * code. 
314  * Setting the LogEvent's valist member is done inside _log_logEvent.
315  */
316
317 #define _XBT_LOG_PRE(catv, priority) do {                        \
318      if (_XBT_LOG_ISENABLEDV(catv, priority)) {                  \
319          s_xbt_log_event_t _log_ev =                             \
320              {NULL,priority,__FILE__,_XBT_FUNCTION,__LINE__};    \
321                 _log_ev.cat = &(catv);                           \
322               _xbt_log_event_log(&_log_ev                        \
323               
324
325 #define _XBT_LOG_POST                          \
326                         );                      \
327      } } while(0)
328
329
330 /* Logging Macros */
331
332 #ifdef XBT_LOG_MAYDAY
333 # define CLOG0(c, p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
334 # define CLOG1(c, p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
335 # define CLOG2(c, p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
336 # define CLOG3(c, p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
337 # define CLOG4(c, p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
338 # define CLOG5(c, p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
339 # 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)
340 # 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)
341 # 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)
342 # 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)
343 # 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)
344 #else
345 # define CLOG0(c, p, f)                   _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f _XBT_LOG_POST            
346 # define CLOG1(c, p, f,a1)                _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1 _XBT_LOG_POST                 
347 # define CLOG2(c, p, f,a1,a2)             _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2 _XBT_LOG_POST
348 # define CLOG3(c, p, f,a1,a2,a3)          _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3 _XBT_LOG_POST
349 # define CLOG4(c, p, f,a1,a2,a3,a4)       _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
350 # 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
351 # 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
352 # 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
353 # 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
354 # 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
355 # 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
356 #endif
357 #define CDEBUG0(c, f)                   CLOG0(c, xbt_log_priority_debug, f)
358 #define CDEBUG1(c, f,a1)                CLOG1(c, xbt_log_priority_debug, f,a1)
359 #define CDEBUG2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_debug, f,a1,a2)
360 #define CDEBUG3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_debug, f,a1,a2,a3)
361 #define CDEBUG4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_debug, f,a1,a2,a3,a4)
362 #define CDEBUG5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
363 #define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
364 #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)
365 #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)
366 #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)
367 /** @ingroup XBT_log
368  *  @hideinitializer
369  * \param c the category on which to log
370  * \param f the format string
371  * \param a1 first argument of the format
372  * \param a2 second argument of the format
373  * \param a3 third argument of the format
374  * \param a4 fourth argument of the format
375  * \param a5 fifth argument of the format
376  * \param a6 sixth argument of the format
377  * \param a7 seventh argument of the format
378  * \param a8 eighth argument of the format
379  * \param a9 ninth argument of the format
380  * \param a10 tenth argument of the format
381  *  @brief Log an event at the DEBUG priority on the specified category with these args (CDEBUGn exists for any n<10).
382  */
383 #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)
384
385 #define CVERB0(c, f)                   CLOG0(c, xbt_log_priority_verbose, f)
386 #define CVERB1(c, f,a1)                CLOG1(c, xbt_log_priority_verbose, f,a1)
387 #define CVERB2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_verbose, f,a1,a2)
388 #define CVERB3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_verbose, f,a1,a2,a3)
389 #define CVERB4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_verbose, f,a1,a2,a3,a4)
390 #define CVERB5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
391 /** @ingroup XBT_log
392  *  @hideinitializer
393  *  @brief Log an event at the VERB priority on the specified category with these args (CVERBn exists for any n<6).
394  */
395 #define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
396
397 #define CINFO0(c, f)                   CLOG0(c, xbt_log_priority_info, f)
398 #define CINFO1(c, f,a1)                CLOG1(c, xbt_log_priority_info, f,a1)
399 #define CINFO2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_info, f,a1,a2)
400 #define CINFO3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_info, f,a1,a2,a3)
401 #define CINFO4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_info, f,a1,a2,a3,a4)
402 #define CINFO5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5)
403 #define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
404 #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)
405 /** @ingroup XBT_log
406  *  @hideinitializer
407  *  @brief Log an event at the INFO priority on the specified category with these args (CINFOn exists for any n<8).
408  */
409 #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)
410
411 #define CWARN0(c, f)                   CLOG0(c, xbt_log_priority_warning, f)
412 #define CWARN1(c, f,a1)                CLOG1(c, xbt_log_priority_warning, f,a1)
413 #define CWARN2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_warning, f,a1,a2)
414 #define CWARN3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_warning, f,a1,a2,a3)
415 #define CWARN4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_warning, f,a1,a2,a3,a4)
416 #define CWARN5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
417 /** @ingroup XBT_log
418  *  @hideinitializer
419  *  @brief Log an event at the WARN priority on the specified category with these args (CWARNn exists for any n<6).
420  */
421 #define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
422
423 #define CERROR0(c, f)                   CLOG0(c, xbt_log_priority_error, f)
424 #define CERROR1(c, f,a1)                CLOG1(c, xbt_log_priority_error, f,a1)
425 #define CERROR2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_error, f,a1,a2)
426 #define CERROR3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_error, f,a1,a2,a3)
427 #define CERROR4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_error, f,a1,a2,a3,a4)
428 #define CERROR5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5)
429 /** @ingroup XBT_log
430  *  @hideinitializer
431  *  @brief Log an event at the ERROR priority on the specified category with these args (CERRORn exists for any n<6).
432  */
433 #define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
434
435 #define CCRITICAL0(c, f)                   CLOG0(c, xbt_log_priority_critical, f)
436 #define CCRITICAL1(c, f,a1)                CLOG1(c, xbt_log_priority_critical, f,a1)
437 #define CCRITICAL2(c, f,a1,a2)             CLOG2(c, xbt_log_priority_critical, f,a1,a2)
438 #define CCRITICAL3(c, f,a1,a2,a3)          CLOG3(c, xbt_log_priority_critical, f,a1,a2,a3)
439 #define CCRITICAL4(c, f,a1,a2,a3,a4)       CLOG4(c, xbt_log_priority_critical, f,a1,a2,a3,a4)
440 #define CCRITICAL5(c, f,a1,a2,a3,a4,a5)    CLOG5(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
441 /** @ingroup XBT_log
442  *  @hideinitializer
443  *  @brief Log an event at the CRITICAL priority on the specified category with these args (CCRITICALn exists for any n<6).
444  */
445 #define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
446
447 #ifdef XBT_LOG_MAYDAY
448 # define LOG0(p, f)                   fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
449 # define LOG1(p, f,a1)                fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)               
450 # define LOG2(p, f,a1,a2)             fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)            
451 # define LOG3(p, f,a1,a2,a3)          fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)         
452 # define LOG4(p, f,a1,a2,a3,a4)       fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)      
453 # define LOG5(p, f,a1,a2,a3,a4,a5)    fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)   
454 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
455 # 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)
456 # 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)
457 # 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)
458 # 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)
459 #else
460 # define LOG0(p, f)                   _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f _XBT_LOG_POST
461 # define LOG1(p, f,a1)                _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1 _XBT_LOG_POST
462 # define LOG2(p, f,a1,a2)             _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2 _XBT_LOG_POST
463 # define LOG3(p, f,a1,a2,a3)          _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3 _XBT_LOG_POST
464 # define LOG4(p, f,a1,a2,a3,a4)       _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
465 # 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
466 # 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
467 # 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
468 # 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
469 # 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
470 # 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
471 #endif
472
473 #define DEBUG0(f)                   LOG0(xbt_log_priority_debug, f)
474 #define DEBUG1(f,a1)                LOG1(xbt_log_priority_debug, f,a1)
475 #define DEBUG2(f,a1,a2)             LOG2(xbt_log_priority_debug, f,a1,a2)
476 #define DEBUG3(f,a1,a2,a3)          LOG3(xbt_log_priority_debug, f,a1,a2,a3)
477 #define DEBUG4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_debug, f,a1,a2,a3,a4)
478 #define DEBUG5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
479 #define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
480 #define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
481 #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)
482 #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)
483 /** @ingroup XBT_log
484  *  @hideinitializer
485  * \param f the format string
486  * \param a1 first argument of the format
487  * \param a2 second argument of the format
488  * \param a3 third argument of the format
489  * \param a4 fourth argument of the format
490  * \param a5 fifth argument of the format
491  * \param a6 sixth argument of the format
492  * \param a7 seventh argument of the format
493  * \param a8 eighth argument of the format
494  * \param a9 ninth argument of the format
495  * \param a10 tenth argument of the format
496  *  @brief Log an event at the DEBUG priority on the default category with these args (DEBUGn exists for any n<10)
497  */
498 #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)
499
500 #define VERB0(f)                   LOG0(xbt_log_priority_verbose, f)
501 #define VERB1(f,a1)                LOG1(xbt_log_priority_verbose, f,a1)
502 #define VERB2(f,a1,a2)             LOG2(xbt_log_priority_verbose, f,a1,a2)
503 #define VERB3(f,a1,a2,a3)          LOG3(xbt_log_priority_verbose, f,a1,a2,a3)
504 #define VERB4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_verbose, f,a1,a2,a3,a4)
505 #define VERB5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
506 /** @ingroup XBT_log
507  *  @hideinitializer
508  *  @brief Log an event at the VERB priority on the default category with these args (VERBn exists for any n<6).
509  */
510 #define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
511
512 #define INFO0(f)                   LOG0(xbt_log_priority_info, f)
513 #define INFO1(f,a1)                LOG1(xbt_log_priority_info, f,a1)
514 #define INFO2(f,a1,a2)             LOG2(xbt_log_priority_info, f,a1,a2)
515 #define INFO3(f,a1,a2,a3)          LOG3(xbt_log_priority_info, f,a1,a2,a3)
516 #define INFO4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_info, f,a1,a2,a3,a4)
517 #define INFO5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_info, f,a1,a2,a3,a4,a5)
518 #define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
519 #define INFO7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7)
520 /** @ingroup XBT_log
521  *  @hideinitializer
522  *  @brief Log an event at the INFO priority on the default category with these args (INFOn exists for any n<8).
523  */
524 #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)
525
526 #define WARN0(f)                   LOG0(xbt_log_priority_warning, f)
527 #define WARN1(f,a1)                LOG1(xbt_log_priority_warning, f,a1)
528 #define WARN2(f,a1,a2)             LOG2(xbt_log_priority_warning, f,a1,a2)
529 #define WARN3(f,a1,a2,a3)          LOG3(xbt_log_priority_warning, f,a1,a2,a3)
530 #define WARN4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_warning, f,a1,a2,a3,a4)
531 #define WARN5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
532 /** @ingroup XBT_log
533  *  @hideinitializer
534  *  @brief Log an event at the WARN priority on the default category with these args (WARNn exists for any n<6).
535  */
536 #define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
537
538 #define ERROR0(f)                   LOG0(xbt_log_priority_error, f)
539 #define ERROR1(f,a1)                LOG1(xbt_log_priority_error, f,a1)
540 #define ERROR2(f,a1,a2)             LOG2(xbt_log_priority_error, f,a1,a2)
541 #define ERROR3(f,a1,a2,a3)          LOG3(xbt_log_priority_error, f,a1,a2,a3)
542 #define ERROR4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_error, f,a1,a2,a3,a4)
543 #define ERROR5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_error, f,a1,a2,a3,a4,a5)
544 /** @ingroup XBT_log
545  *  @hideinitializer
546  *  @brief Log an event at the ERROR priority on the default category with these args (ERRORn exists for any n<6).
547  */
548 #define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
549
550 #define CRITICAL0(f)                   LOG0(xbt_log_priority_critical, f)
551 #define CRITICAL1(f,a1)                LOG1(xbt_log_priority_critical, f,a1)
552 #define CRITICAL2(f,a1,a2)             LOG2(xbt_log_priority_critical, f,a1,a2)
553 #define CRITICAL3(f,a1,a2,a3)          LOG3(xbt_log_priority_critical, f,a1,a2,a3)
554 #define CRITICAL4(f,a1,a2,a3,a4)       LOG4(xbt_log_priority_critical, f,a1,a2,a3,a4)
555 #define CRITICAL5(f,a1,a2,a3,a4,a5)    LOG5(xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
556 /** @ingroup XBT_log
557  *  @hideinitializer
558  *  @brief Log an event at the CRITICAL priority on the default category with these args (CRITICALn exists for any n<6).
559  */
560 #define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
561
562 /** @ingroup XBT_log
563  *  @hideinitializer
564  *  @brief Log at TRACE priority that we entered in current function.
565  */
566 #define XBT_IN               LOG1(xbt_log_priority_trace, ">> begin of %s",     _XBT_FUNCTION)
567 #define XBT_IN1(fmt,a)       LOG2(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a)
568 #define XBT_IN2(fmt,a,b)     LOG3(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b)
569 #define XBT_IN3(fmt,a,b,c)   LOG4(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c)
570 #define XBT_IN4(fmt,a,b,c,d) LOG5(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c,d)
571 /** @ingroup XBT_log
572  *  @hideinitializer
573  *  @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])
574  */
575 #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)
576 /** @ingroup XBT_log
577  *  @hideinitializer
578  *  @brief Log at TRACE priority that we exited the current function.
579  */
580 #define XBT_OUT              LOG1(xbt_log_priority_trace, "<< end of %s",       _XBT_FUNCTION)
581 /** @ingroup XBT_log
582  *  @hideinitializer
583  *  @brief Log at TRACE priority a message indicating that we reached that point.
584  */
585 #define XBT_HERE             LOG0(xbt_log_priority_trace, "-- was here")
586 SG_END_DECL()
587
588 #endif /* ! _XBT_LOG_H_ */