#include <functional>
#include <xbt/log.h>
+/* Returns c-string "s" if n > 1, empty string "" otherwise. */
+#define ESSE(n) (misc::str_esse + ((n) <= 1))
+
+namespace misc {
+ extern const char str_esse[];
+}
+
/* Returns true if the given priority is enabled for the default
* category. Priority is xbt_log_priority_SUFFIX, where SUFFIX may
* be: trace, debug, verbose, info, warning, error, critical.
#define LOG_ISENABLED(priority) \
(_XBT_LOG_ISENABLEDV((*_XBT_LOGV(default)), (priority)))
-/* Defines XCLOGn(...) which behave like CLOGn(...), except that the
- * given category is not passed through _XBT_LOGV before use.
- */
-#ifdef XBT_CLOG_
-# define XBT_XCLOG(c, p, ...) XBT_CLOG_((*(c)), p, __VA_ARGS__)
-# define XCLOG0(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG1(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG2(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG3(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG4(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG5(...) XBT_XCLOG(__VA_ARGS__)
-# define XCLOG6(...) XBT_XCLOG(__VA_ARGS__)
-#else
-# define XCLOG0(c, p, f) _XBT_LOG_PRE((*(c)),p) ,f _XBT_LOG_POST
-# define XCLOG1(c, p, f,a1) _XBT_LOG_PRE((*(c)),p) ,f,a1 _XBT_LOG_POST
-# define XCLOG2(c, p, f,a1,a2) _XBT_LOG_PRE((*(c)),p) ,f,a1,a2 _XBT_LOG_POST
-# define XCLOG3(c, p, f,a1,a2,a3) _XBT_LOG_PRE((*(c)),p) ,f,a1,a2,a3 _XBT_LOG_POST
-# define XCLOG4(c, p, f,a1,a2,a3,a4) _XBT_LOG_PRE((*(c)),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
-# define XCLOG5(c, p, f,a1,a2,a3,a4,a5) _XBT_LOG_PRE((*(c)),p) ,f,a1,a2,a3,a4,a5 _XBT_LOG_POST
-# define XCLOG6(c, p, f,a1,a2,a3,a4,a5,a6) _XBT_LOG_PRE((*(c)),p) ,f,a1,a2,a3,a4,a5,a6 _XBT_LOG_POST
+#ifndef XBT_CLOG
+# define XBT_CLOG_(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, __VA_ARGS__); \
+ } \
+ } while (0)
+# define XBT_CLOG(c, p, ...) XBT_CLOG_(_XBT_LOGV(c), p, __VA_ARGS__)
+# define XBT_CDEBUG(c, ...) XBT_CLOG(c, xbt_log_priority_debug, __VA_ARGS__)
+# define XBT_CVERB(c, ...) XBT_CLOG(c, xbt_log_priority_verbose, __VA_ARGS__)
+# define XBT_CINFO(c, ...) XBT_CLOG(c, xbt_log_priority_info, __VA_ARGS__)
+# define XBT_CWARN(c, ...) XBT_CLOG(c, xbt_log_priority_warning, __VA_ARGS__)
+# define XBT_CERROR(c, ...) XBT_CLOG(c, xbt_log_priority_error, __VA_ARGS__)
+# define XBT_CCRITICAL(c, ...) XBT_CLOG(c, xbt_log_priority_critical, __VA_ARGS__)
+# define XBT_LOG(...) XBT_CLOG_((*_XBT_LOGV(default)), __VA_ARGS__)
+# define XBT_DEBUG(...) XBT_LOG(xbt_log_priority_debug, __VA_ARGS__)
+# define XBT_VERB(...) XBT_LOG(xbt_log_priority_verbose, __VA_ARGS__)
+# define XBT_INFO(...) XBT_LOG(xbt_log_priority_info, __VA_ARGS__)
+# define XBT_WARN(...) XBT_LOG(xbt_log_priority_warning, __VA_ARGS__)
+# define XBT_ERROR(...) XBT_LOG(xbt_log_priority_error, __VA_ARGS__)
+# define XBT_CRITICAL(...) XBT_LOG(xbt_log_priority_critical, __VA_ARGS__)
#endif
-/* Returns c-string "s" if n > 1, empty string "" otherwise. */
-#define ESSE(n) (misc::str_esse + ((n) <= 1))
-
-namespace misc {
- extern const char str_esse[];
-}
+/* Defines XBT_XCLOG(...) which behave like XBT_CLOG(...), except that the
+ * given category is not passed through _XBT_LOGV before use.
+ */
+#define XBT_XCLOG(c, p, ...) XBT_CLOG_((*(c)), p, __VA_ARGS__)
#endif // !MISC_H