1 /* log - a generic logging facility in the spirit of log4j */
3 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 /** @addtogroup XBT_log
10 * @brief A generic logging facility in the spirit of log4j (grounding feature)
15 /** \defgroup XBT_log_cats Existing log categories
17 * \brief (automatically extracted)
19 * This is the list of all existing log categories in SimGrid.
20 * This list was automatically extracted from the source code by
21 * the src/xbt_log_extract_hierarchy utility.
23 * You can thus be certain that it is uptodate, but it may somehow
24 * lack a final manual touch.
25 * Anyway, nothing's perfect ;)
28 /* XBT_LOG_MAYDAY: define this to replace the logging facilities with basic
29 printf function. Useful to debug the logging facilities themselves */
31 //#define XBT_LOG_MAYDAY
39 /**\brief Log priorities
42 * The different existing priorities.
45 xbt_log_priority_none = 0, /* used internally (don't poke with) */
46 xbt_log_priority_trace = 1, /**< enter and return of some functions */
47 xbt_log_priority_debug = 2, /**< crufty output */
48 xbt_log_priority_verbose = 3, /**< verbose output for the user wanting more */
49 xbt_log_priority_info = 4, /**< output about the regular functionning */
50 xbt_log_priority_warning = 5, /**< minor issue encountered */
51 xbt_log_priority_error = 6, /**< issue encountered */
52 xbt_log_priority_critical = 7, /**< major issue encountered */
54 xbt_log_priority_infinite = 8, /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
56 xbt_log_priority_uninitialized = -1 /* used internally (don't poke with) */
57 } e_xbt_log_priority_t;
61 * define NLOG to disable at compilation time any logging request
62 * define NDEBUG to disable at compilation time any logging request of priority below INFO
67 * @def XBT_LOG_STATIC_THRESHOLD
70 * All logging requests with priority < XBT_LOG_STATIC_THRESHOLD are disabled at
71 * compile time, i.e., compiled out.
74 # define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_infinite
78 # define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_verbose
79 # else /* !NLOG && !NDEBUG */
81 # ifndef XBT_LOG_STATIC_THRESHOLD
82 # define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_none
83 # endif /* !XBT_LOG_STATIC_THRESHOLD */
85 #endif /* !defined(NLOG) */
87 /* Transforms a category name to a global variable name. */
88 #define _XBT_LOGV(cat) _XBT_LOG_CONCAT(_simgrid_log_category__, cat)
89 #define _XBT_LOG_CONCAT(x,y) x ## y
91 /* The root of the category hierarchy. */
92 #define XBT_LOG_ROOT_CAT root
94 /* The whole tree of categories is connected by setting the address of
95 * the parent category as a field of the child one.
97 * In strict ansi C, we are allowed to initialize a variable with "a
98 * pointer to an lvalue designating an object of static storage
99 * duration" [ISO/IEC 9899:1999, Section 6.6].
101 * Unfortunately, Visual C builder does not target any standard
102 * compliance, and C99 is not an exception to this unfortunate rule.
104 * So, we work this around by adding a XBT_LOG_CONNECT() macro,
105 * allowing to connect a child to its parent. It should be used
106 * during the initialization of the code, before the child category
109 * When compiling with gcc, this is not necessary (XBT_LOG_CONNECT
110 * defines to nothing). When compiling with MSVC, this is needed if
111 * you don't want to see your child category become a child of root
114 #if defined(_MSC_VER)
115 # define _XBT_LOG_PARENT_INITIALIZER(parent) NULL
116 # define XBT_LOG_CONNECT(parent_cat,child) _XBT_LOGV(child).parent = &_XBT_LOGV(parent_cat)
118 # define _XBT_LOG_PARENT_INITIALIZER(parent) &_XBT_LOGV(parent)
119 # define XBT_LOG_CONNECT(parent_cat,child) /* xbt_assert(_XBT_LOGV(child).parent == &_XBT_LOGV(parent_cat)) */
122 /* XBT_LOG_NEW_SUBCATEGORY_helper:
123 * Implementation of XBT_LOG_NEW_SUBCATEGORY, which must declare "extern parent" in addition
124 * to avoid an extra declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by
125 * XBT_LOG_NEW_CATEGORY */
126 #define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
127 XBT_EXPORT_NO_IMPORT(s_xbt_log_category_t) _XBT_LOGV(catName) = { \
128 _XBT_LOG_PARENT_INITIALIZER(parent), \
129 NULL /* firstChild */, \
130 NULL /* nextSibling */, \
132 xbt_log_priority_uninitialized /* threshold */, \
133 1 /* isThreshInherited */, \
134 NULL /* appender */, \
140 * \param catName name of new category
141 * \param parent father of the new category in the tree
142 * \param desc string describing the purpose of this category
145 * Defines a new subcategory of the parent.
147 #define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
148 extern s_xbt_log_category_t _XBT_LOGV(parent); \
149 XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
153 * \param catName name of new category
154 * \param desc string describing the purpose of this category
157 * Creates a new subcategory of the root category.
159 # define XBT_LOG_NEW_CATEGORY(catName,desc) \
160 XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc)
165 * \param cname name of the cat
168 * Indicates which category is the default one.
171 #if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
172 # define XBT_LOG_DEFAULT_CATEGORY(cname)
174 # define XBT_LOG_DEFAULT_CATEGORY(cname) \
175 static xbt_log_category_t _XBT_LOGV(default) _XBT_GNUC_UNUSED = &_XBT_LOGV(cname)
180 * \param cname name of the cat
181 * \param desc string describing the purpose of this category
184 * Creates a new subcategory of the root category and makes it the default
185 * (used by macros that don't explicitly specify a category).
187 # define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \
188 XBT_LOG_NEW_CATEGORY(cname,desc); \
189 XBT_LOG_DEFAULT_CATEGORY(cname)
193 * \param cname name of the cat
194 * \param parent name of the parent
195 * \param desc string describing the purpose of this category
198 * Creates a new subcategory of the parent category and makes it the default
199 * (used by macros that don't explicitly specify a category).
201 #define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
202 XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc); \
203 XBT_LOG_DEFAULT_CATEGORY(cname)
207 * \param cname name of the cat
210 * Indicates that a category you'll use in this file (to get subcategories of it,
211 * for example) really lives in another file.
214 #define XBT_LOG_EXTERNAL_CATEGORY(cname) \
215 extern s_xbt_log_category_t _XBT_LOGV(cname)
219 * \param cname name of the cat
222 * Indicates that the default category of this file was declared in another file.
225 #define XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(cname) \
226 XBT_LOG_EXTERNAL_CATEGORY(cname);\
227 XBT_LOG_DEFAULT_CATEGORY(cname)
229 /* Functions you may call */
231 XBT_PUBLIC(void) xbt_log_control_set(const char *cs);
233 /* Forward declarations */
234 typedef struct xbt_log_appender_s s_xbt_log_appender_t,
236 typedef struct xbt_log_layout_s s_xbt_log_layout_t, *xbt_log_layout_t;
237 typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
238 typedef struct xbt_log_category_s s_xbt_log_category_t,
242 * Do NOT access any members of this structure directly. FIXME: move to private?
245 #define XBT_LOG_BUFF_SIZE 16384 /* Size of the static string in which we build the log string */
247 #define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */
249 struct xbt_log_category_s {
250 xbt_log_category_t parent;
251 xbt_log_category_t firstChild;
252 xbt_log_category_t nextSibling;
255 int isThreshInherited;
256 xbt_log_appender_t appender;
257 xbt_log_layout_t layout;
261 struct xbt_log_event_s {
262 xbt_log_category_t cat;
263 e_xbt_log_priority_t priority;
264 const char *fileName;
265 const char *functionName;
268 va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
272 char buffer[XBT_LOG_BUFF_SIZE];
277 * \ingroup XBT_log_implem
278 * \param cat the category (not only its name, but the variable)
279 * \param thresholdPriority the priority
281 * Programatically alters a category's threshold priority (don't use).
283 XBT_PUBLIC(void) xbt_log_threshold_set(xbt_log_category_t cat,
288 * \ingroup XBT_log_implem
289 * \param cat the category (not only its name, but the variable)
290 * \param app the appender
292 * Programatically sets the category's appender.
293 * (the prefered interface is throught xbt_log_control_set())
296 XBT_PUBLIC(void) xbt_log_appender_set(xbt_log_category_t cat,
297 xbt_log_appender_t app);
299 * \ingroup XBT_log_implem
300 * \param cat the category (not only its name, but the variable)
301 * \param lay the layout
303 * Programatically sets the category's layout.
304 * (the prefered interface is throught xbt_log_control_set())
307 XBT_PUBLIC(void) xbt_log_layout_set(xbt_log_category_t cat,
308 xbt_log_layout_t lay);
311 * \ingroup XBT_log_implem
312 * \param cat the category (not only its name, but the variable)
313 * \param additivity whether logging actions must be passed to parent.
315 * Programatically sets whether the logging actions must be passed to
316 * the parent category.
317 * (the prefered interface is throught xbt_log_control_set())
320 XBT_PUBLIC(void) xbt_log_additivity_set(xbt_log_category_t cat,
323 /** @brief create a new simple layout
325 * This layout is not as flexible as the pattern one
327 XBT_PUBLIC(xbt_log_layout_t) xbt_log_layout_simple_new(char *arg);
328 XBT_PUBLIC(xbt_log_layout_t) xbt_log_layout_format_new(char *arg);
329 XBT_PUBLIC(xbt_log_appender_t) xbt_log_appender_file_new(char *arg);
332 /* ********************************** */
333 /* Functions that you shouldn't call */
334 /* ********************************** */
335 XBT_PUBLIC(void) _xbt_log_event_log(xbt_log_event_t ev,
337 ...) _XBT_GNUC_PRINTF(2, 3);
339 XBT_PUBLIC(int) _xbt_log_cat_init(xbt_log_category_t category,
340 e_xbt_log_priority_t priority);
343 XBT_PUBLIC_DATA(s_xbt_log_category_t) _XBT_LOGV(XBT_LOG_ROOT_CAT);
346 extern xbt_log_appender_t xbt_log_default_appender;
347 extern xbt_log_layout_t xbt_log_default_layout;
349 /* ********************** */
350 /* Public functions again */
351 /* ********************** */
355 * \param catName name of the category
356 * \param priority minimal priority to be enabled to return true (must be #e_xbt_log_priority_t)
359 * Returns true if the given priority is enabled for the category.
360 * If you have expensive expressions that are computed outside of the log
361 * command and used only within it, you should make its evaluation conditional
364 #define XBT_LOG_ISENABLED(catName, priority) \
365 _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
368 * Helper function that implements XBT_LOG_ISENABLED.
371 * First part is a compile-time constant.
372 * Call to _log_initCat only happens once.
374 #define _XBT_LOG_ISENABLEDV(catv, priority) \
375 (priority >= XBT_LOG_STATIC_THRESHOLD \
376 && priority >= catv.threshold \
377 && (catv.threshold != xbt_log_priority_uninitialized \
378 || _xbt_log_cat_init(&catv, priority)) )
382 * Some kludge macros to ease maintenance. See how they're used below.
384 * IMPLEMENTATION NOTE: To reduce the parameter passing overhead of an enabled
385 * message, the many parameters passed to the logging function are packed in a
386 * structure. Since these values will be usually be passed to at least 3
387 * functions, this is a win.
388 * It also allows adding new values (such as a timestamp) without breaking
390 * Setting the LogEvent's valist member is done inside _log_logEvent.
393 #include <stdlib.h> /* calloc */
394 #define _XBT_LOG_PRE(catv, prio) do { \
395 if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
396 s_xbt_log_event_t _log_ev; \
397 _log_ev.cat = &(catv); \
398 _log_ev.priority = (prio); \
399 _log_ev.fileName = __FILE__; \
400 _log_ev.functionName = _XBT_FUNCTION; \
401 _log_ev.lineNum = __LINE__; \
402 _log_ev.buffer = (char*) calloc(XBT_LOG_BUFF_SIZE + 1, sizeof(char)); \
403 _xbt_log_event_log(&_log_ev
405 #include <string.h> /* memset */
406 #define _XBT_LOG_PRE(catv, prio) do { \
407 if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
408 s_xbt_log_event_t _log_ev; \
409 _log_ev.cat = &(catv); \
410 _log_ev.priority = (prio); \
411 _log_ev.fileName = __FILE__; \
412 _log_ev.functionName = _XBT_FUNCTION; \
413 _log_ev.lineNum = __LINE__; \
414 memset(_log_ev.buffer, 0, XBT_LOG_BUFF_SIZE); \
415 _xbt_log_event_log(&_log_ev
419 #define _XBT_LOG_POST \
426 #ifdef XBT_LOG_MAYDAY
427 # define CLOG0(c, p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
428 # define CLOG1(c, p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
429 # define CLOG2(c, p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
430 # define CLOG3(c, p, f,a1,a2,a3) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)
431 # define CLOG4(c, p, f,a1,a2,a3,a4) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)
432 # define CLOG5(c, p, f,a1,a2,a3,a4,a5) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)
433 # 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)
434 # 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)
435 # 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)
436 # 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)
437 # 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)
439 # define CLOG0(c, p, f) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f _XBT_LOG_POST
440 # define CLOG1(c, p, f,a1) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1 _XBT_LOG_POST
441 # define CLOG2(c, p, f,a1,a2) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2 _XBT_LOG_POST
442 # define CLOG3(c, p, f,a1,a2,a3) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3 _XBT_LOG_POST
443 # define CLOG4(c, p, f,a1,a2,a3,a4) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
444 # 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
445 # 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
446 # 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
447 # 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
448 # 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
449 # 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
451 #define CDEBUG0(c, f) CLOG0(c, xbt_log_priority_debug, f)
452 #define CDEBUG1(c, f,a1) CLOG1(c, xbt_log_priority_debug, f,a1)
453 #define CDEBUG2(c, f,a1,a2) CLOG2(c, xbt_log_priority_debug, f,a1,a2)
454 #define CDEBUG3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_debug, f,a1,a2,a3)
455 #define CDEBUG4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_debug, f,a1,a2,a3,a4)
456 #define CDEBUG5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
457 #define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
458 #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)
459 #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)
460 #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)
463 * \param c the category on which to log
464 * \param f the format string
465 * \param a1 first argument of the format
466 * \param a2 second argument of the format
467 * \param a3 third argument of the format
468 * \param a4 fourth argument of the format
469 * \param a5 fifth argument of the format
470 * \param a6 sixth argument of the format
471 * \param a7 seventh argument of the format
472 * \param a8 eighth argument of the format
473 * \param a9 ninth argument of the format
474 * \param a10 tenth argument of the format
475 * @brief Log an event at the DEBUG priority on the specified category with these args (CDEBUGn exists for any n<10).
477 #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)
479 #define CVERB0(c, f) CLOG0(c, xbt_log_priority_verbose, f)
480 #define CVERB1(c, f,a1) CLOG1(c, xbt_log_priority_verbose, f,a1)
481 #define CVERB2(c, f,a1,a2) CLOG2(c, xbt_log_priority_verbose, f,a1,a2)
482 #define CVERB3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_verbose, f,a1,a2,a3)
483 #define CVERB4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_verbose, f,a1,a2,a3,a4)
484 #define CVERB5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
485 #define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
486 #define CVERB7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7)
487 #define CVERB8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8)
488 #define CVERB9(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9) CLOG9(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
491 * @brief Log an event at the VERB priority on the specified category with these args (CVERBn exists for any n<10).
493 #define CVERB10(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) CLOG10(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
495 #define CINFO0(c, f) CLOG0(c, xbt_log_priority_info, f)
496 #define CINFO1(c, f,a1) CLOG1(c, xbt_log_priority_info, f,a1)
497 #define CINFO2(c, f,a1,a2) CLOG2(c, xbt_log_priority_info, f,a1,a2)
498 #define CINFO3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_info, f,a1,a2,a3)
499 #define CINFO4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_info, f,a1,a2,a3,a4)
500 #define CINFO5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5)
501 #define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
502 #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)
503 #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)
504 #define CINFO9(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9) CLOG9(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
507 * @brief Log an event at the INFO priority on the specified category with these args (CINFOn exists for any n<10).
509 #define CINFO10(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) CLOG10(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
511 #define CWARN0(c, f) CLOG0(c, xbt_log_priority_warning, f)
512 #define CWARN1(c, f,a1) CLOG1(c, xbt_log_priority_warning, f,a1)
513 #define CWARN2(c, f,a1,a2) CLOG2(c, xbt_log_priority_warning, f,a1,a2)
514 #define CWARN3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_warning, f,a1,a2,a3)
515 #define CWARN4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_warning, f,a1,a2,a3,a4)
516 #define CWARN5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
517 #define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
518 #define CWARN7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7)
519 #define CWARN8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8)
520 #define CWARN9(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9) CLOG9(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
523 * @brief Log an event at the WARN priority on the specified category with these args (CWARNn exists for any n<10).
525 #define CWARN10(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) CLOG10(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,10)
527 #define CERROR0(c, f) CLOG0(c, xbt_log_priority_error, f)
528 #define CERROR1(c, f,a1) CLOG1(c, xbt_log_priority_error, f,a1)
529 #define CERROR2(c, f,a1,a2) CLOG2(c, xbt_log_priority_error, f,a1,a2)
530 #define CERROR3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_error, f,a1,a2,a3)
531 #define CERROR4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_error, f,a1,a2,a3,a4)
532 #define CERROR5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5)
533 #define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
534 #define CERROR7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7)
535 #define CERROR8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8)
536 #define CERROR9(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9) CLOG9(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
539 * @brief Log an event at the ERROR priority on the specified category with these args (CERRORn exists for any n<10).
541 #define CERROR10(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) CLOG10(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
543 #define CCRITICAL0(c, f) CLOG0(c, xbt_log_priority_critical, f)
544 #define CCRITICAL1(c, f,a1) CLOG1(c, xbt_log_priority_critical, f,a1)
545 #define CCRITICAL2(c, f,a1,a2) CLOG2(c, xbt_log_priority_critical, f,a1,a2)
546 #define CCRITICAL3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_critical, f,a1,a2,a3)
547 #define CCRITICAL4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_critical, f,a1,a2,a3,a4)
548 #define CCRITICAL5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
549 #define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
550 #define CCRITICAL7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7)
551 #define CCRITICAL8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8)
552 #define CCRITICAL9(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9) CLOG9(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
555 * @brief Log an event at the CRITICAL priority on the specified category with these args (CCRITICALn exists for any n<10).
557 #define CCRITICAL10(c, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) CLOG10(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
559 #ifdef XBT_LOG_MAYDAY
560 # define LOG0(p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
561 # define LOG1(p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
562 # define LOG2(p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
563 # define LOG3(p, f,a1,a2,a3) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3)
564 # define LOG4(p, f,a1,a2,a3,a4) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4)
565 # define LOG5(p, f,a1,a2,a3,a4,a5) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5)
566 # define LOG6(p, f,a1,a2,a3,a4,a5,a6) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6)
567 # 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)
568 # 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)
569 # 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)
570 # 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)
572 # define LOG0(p, f) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f _XBT_LOG_POST
573 # define LOG1(p, f,a1) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1 _XBT_LOG_POST
574 # define LOG2(p, f,a1,a2) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2 _XBT_LOG_POST
575 # define LOG3(p, f,a1,a2,a3) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3 _XBT_LOG_POST
576 # define LOG4(p, f,a1,a2,a3,a4) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
577 # 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
578 # 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
579 # 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
580 # 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
581 # 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
582 # 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
585 #define DEBUG0(f) LOG0(xbt_log_priority_debug, f)
586 #define DEBUG1(f,a1) LOG1(xbt_log_priority_debug, f,a1)
587 #define DEBUG2(f,a1,a2) LOG2(xbt_log_priority_debug, f,a1,a2)
588 #define DEBUG3(f,a1,a2,a3) LOG3(xbt_log_priority_debug, f,a1,a2,a3)
589 #define DEBUG4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_debug, f,a1,a2,a3,a4)
590 #define DEBUG5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
591 #define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
592 #define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
593 #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)
594 #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)
597 * \param f the format string
598 * \param a1 first argument of the format
599 * \param a2 second argument of the format
600 * \param a3 third argument of the format
601 * \param a4 fourth argument of the format
602 * \param a5 fifth argument of the format
603 * \param a6 sixth argument of the format
604 * \param a7 seventh argument of the format
605 * \param a8 eighth argument of the format
606 * \param a9 ninth argument of the format
607 * \param a10 tenth argument of the format
608 * @brief Log an event at the DEBUG priority on the default category with these args (DEBUGn exists for any n<10)
610 #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)
612 #define VERB0(f) LOG0(xbt_log_priority_verbose, f)
613 #define VERB1(f,a1) LOG1(xbt_log_priority_verbose, f,a1)
614 #define VERB2(f,a1,a2) LOG2(xbt_log_priority_verbose, f,a1,a2)
615 #define VERB3(f,a1,a2,a3) LOG3(xbt_log_priority_verbose, f,a1,a2,a3)
616 #define VERB4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_verbose, f,a1,a2,a3,a4)
617 #define VERB5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
618 #define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
619 #define VERB7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7)
620 #define VERB8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8)
621 #define VERB9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) LOG9(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
624 * @brief Log an event at the VERB priority on the default category with these args (VERBn exists for any n<10).
626 #define VERB10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) LOG10(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
628 #define INFO0(f) LOG0(xbt_log_priority_info, f)
629 #define INFO1(f,a1) LOG1(xbt_log_priority_info, f,a1)
630 #define INFO2(f,a1,a2) LOG2(xbt_log_priority_info, f,a1,a2)
631 #define INFO3(f,a1,a2,a3) LOG3(xbt_log_priority_info, f,a1,a2,a3)
632 #define INFO4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_info, f,a1,a2,a3,a4)
633 #define INFO5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_info, f,a1,a2,a3,a4,a5)
634 #define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
635 #define INFO7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7)
636 #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)
637 #define INFO9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) LOG9(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
640 * @brief Log an event at the INFO priority on the default category with these args (INFOn exists for any n<10).
642 #define INFO10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) LOG10(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
644 #define WARN0(f) LOG0(xbt_log_priority_warning, f)
645 #define WARN1(f,a1) LOG1(xbt_log_priority_warning, f,a1)
646 #define WARN2(f,a1,a2) LOG2(xbt_log_priority_warning, f,a1,a2)
647 #define WARN3(f,a1,a2,a3) LOG3(xbt_log_priority_warning, f,a1,a2,a3)
648 #define WARN4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_warning, f,a1,a2,a3,a4)
649 #define WARN5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
650 #define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
651 #define WARN7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7)
652 #define WARN8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8)
653 #define WARN9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) LOG9(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
656 * @brief Log an event at the WARN priority on the default category with these args (WARNn exists for any n<10).
658 #define WARN10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) LOG10(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
661 #define ERROR0(f) LOG0(xbt_log_priority_error, f)
662 #define ERROR1(f,a1) LOG1(xbt_log_priority_error, f,a1)
663 #define ERROR2(f,a1,a2) LOG2(xbt_log_priority_error, f,a1,a2)
664 #define ERROR3(f,a1,a2,a3) LOG3(xbt_log_priority_error, f,a1,a2,a3)
665 #define ERROR4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_error, f,a1,a2,a3,a4)
666 #define ERROR5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_error, f,a1,a2,a3,a4,a5)
667 #define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
668 #define ERROR7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7)
669 #define ERROR8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8)
670 #define ERROR9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) LOG9(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
673 * @brief Log an event at the ERROR priority on the default category with these args (ERRORn exists for any n<10).
675 #define ERROR10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) LOG10(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
677 #define CRITICAL0(f) LOG0(xbt_log_priority_critical, f)
678 #define CRITICAL1(f,a1) LOG1(xbt_log_priority_critical, f,a1)
679 #define CRITICAL2(f,a1,a2) LOG2(xbt_log_priority_critical, f,a1,a2)
680 #define CRITICAL3(f,a1,a2,a3) LOG3(xbt_log_priority_critical, f,a1,a2,a3)
681 #define CRITICAL4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_critical, f,a1,a2,a3,a4)
682 #define CRITICAL5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
683 #define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
684 #define CRITICAL7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7)
685 #define CRITICAL8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8)
686 #define CRITICAL9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) LOG9(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
689 * @brief Log an event at the CRITICAL priority on the default category with these args (CRITICALn exists for any n<10).
691 #define CRITICAL10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) LOG10(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
695 * @brief Log at TRACE priority that we entered in current function.
697 #define XBT_IN LOG1(xbt_log_priority_trace, ">> begin of %s", _XBT_FUNCTION)
698 #define XBT_IN1(fmt,a) LOG2(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a)
699 #define XBT_IN2(fmt,a,b) LOG3(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b)
700 #define XBT_IN3(fmt,a,b,c) LOG4(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c)
701 #define XBT_IN4(fmt,a,b,c,d) LOG5(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c,d)
704 * @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])
706 #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)
707 #define XBT_IN6(fmt,a,b,c,d,e,f) LOG7(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, a,b,c,d,e,f)
710 * @brief Log at TRACE priority that we exited the current function.
712 #define XBT_OUT LOG1(xbt_log_priority_trace, "<< end of %s", _XBT_FUNCTION)
715 * @brief Log at TRACE priority a message indicating that we reached that point.
717 #define XBT_HERE LOG0(xbt_log_priority_trace, "-- was here")
721 #endif /* ! _XBT_LOG_H_ */