-/* $Id$ */
-
/* log - a generic logging facility in the spirit of log4j */
-/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
+/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* The root of the category hierarchy. */
#define XBT_LOG_ROOT_CAT root
-/* In stric ansi C, we are not allowed to initialize a variable with
- * a non-constant value. But the whole tree of categories is
- * connected by setting the address of the parent category as a field
- * of the child one.
+/* The whole tree of categories is connected by setting the address of
+ * the parent category as a field of the child one.
+ *
+ * In strict ansi C, we are allowed to initialize a variable with "a
+ * pointer to an lvalue designating an object of static storage
+ * duration" [ISO/IEC 9899:1999, Section 6.6].
*
* Unfortunately, Visual C builder does not target any standard
* compliance, and C99 is not an exception to this unfortunate rule.
* you don't want to see your child category become a child of root
* directly.
*/
-#if defined(__STRICT_ANSI__) || defined(_MSC_VER)
+#if defined(_MSC_VER)
# define _XBT_LOG_PARENT_INITIALIZER(parent) NULL
# define XBT_LOG_CONNECT(parent_cat,child) _XBT_LOGV(child).parent = &_XBT_LOGV(parent_cat)
#else
* Indicates which category is the default one.
*/
-#if defined(XBT_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
+#if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
# define XBT_LOG_DEFAULT_CATEGORY(cname)
#else
# define XBT_LOG_DEFAULT_CATEGORY(cname) \
/*
* Do NOT access any members of this structure directly. FIXME: move to private?
*/
-#ifdef WIN32
+#ifdef _XBT_WIN32
#define XBT_LOG_BUFF_SIZE 16384 /* Size of the static string in which we build the log string */
#else
#define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */
int lineNum;
va_list ap;
va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
-#ifdef WIN32
+#ifdef _XBT_WIN32
char *buffer;
#else
char buffer[XBT_LOG_BUFF_SIZE];
* code.
* Setting the LogEvent's valist member is done inside _log_logEvent.
*/
-#ifdef WIN32
-#define _XBT_LOG_PRE(catv, priority) do { \
- if (_XBT_LOG_ISENABLEDV(catv, priority)) { \
- s_xbt_log_event_t _log_ev = \
- {NULL,priority,__FILE__,_XBT_FUNCTION,__LINE__}; \
- _log_ev.cat = &(catv); \
- _log_ev.buffer = (char*) calloc(XBT_LOG_BUFF_SIZE + 1, sizeof(char)); \
- _xbt_log_event_log(&_log_ev
+#ifdef _XBT_WIN32
+#define _XBT_LOG_PRE(catv, prio) do { \
+ if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
+ s_xbt_log_event_t _log_ev; \
+ _log_ev.cat = &(catv); \
+ _log_ev.priority = (prio); \
+ _log_ev.fileName = __FILE__; \
+ _log_ev.functionName = _XBT_FUNCTION; \
+ _log_ev.lineNum = __LINE__; \
+ _log_ev.buffer = (char*) calloc(XBT_LOG_BUFF_SIZE + 1, sizeof(char)); \
+ _xbt_log_event_log(&_log_ev
#else
-#define _XBT_LOG_PRE(catv, priority) do { \
- if (_XBT_LOG_ISENABLEDV(catv, priority)) { \
- s_xbt_log_event_t _log_ev = \
- {NULL,priority,__FILE__,_XBT_FUNCTION,__LINE__}; \
- _log_ev.cat = &(catv); \
- _xbt_log_event_log(&_log_ev \
+#define _XBT_LOG_PRE(catv, prio) do { \
+ if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
+ s_xbt_log_event_t _log_ev; \
+ _log_ev.cat = &(catv); \
+ _log_ev.priority = (prio); \
+ _log_ev.fileName = __FILE__; \
+ _log_ev.functionName = _XBT_FUNCTION; \
+ _log_ev.lineNum = __LINE__; \
+ memset(_log_ev.buffer, 0, XBT_LOG_BUFF_SIZE); \
+ _xbt_log_event_log(&_log_ev
#endif