15 #ifndef STXXL_VERBOSE_HEADER
16 #define STXXL_VERBOSE_HEADER
25 #define _STXXL_PRNT_COUT (1 << 0)
26 #define _STXXL_PRNT_CERR (1 << 1)
27 #define _STXXL_PRNT_LOG (1 << 2)
28 #define _STXXL_PRNT_ERRLOG (1 << 3)
29 #define _STXXL_PRNT_ADDNEWLINE (1 << 16)
30 #define _STXXL_PRNT_TIMESTAMP (1 << 17)
31 #define _STXXL_PRNT_THREAD_ID (1 << 18)
33 #define _STXXL_PRINT_FLAGS_DEFAULT (_STXXL_PRNT_COUT | _STXXL_PRNT_LOG)
34 #define _STXXL_PRINT_FLAGS_ERROR (_STXXL_PRNT_CERR | _STXXL_PRNT_ERRLOG)
35 #define _STXXL_PRINT_FLAGS_VERBOSE (_STXXL_PRINT_FLAGS_DEFAULT | _STXXL_PRNT_TIMESTAMP | _STXXL_PRNT_THREAD_ID)
40 void print_msg(
const char* label,
const std::string& msg,
unsigned flags);
45 #define _STXXL_PRINT(label, message, flags) \
47 std::ostringstream str_; \
49 stxxl::print_msg(label, str_.str(), flags | _STXXL_PRNT_ADDNEWLINE); \
52 #define _STXXL_NOT_VERBOSE do { } while (false)
55 #ifdef STXXL_FORCE_VERBOSE_LEVEL
56 #undef STXXL_VERBOSE_LEVEL
57 #define STXXL_VERBOSE_LEVEL STXXL_FORCE_VERBOSE_LEVEL
60 #ifdef STXXL_DEFAULT_VERBOSE_LEVEL
61 #ifndef STXXL_VERBOSE_LEVEL
62 #define STXXL_VERBOSE_LEVEL STXXL_DEFAULT_VERBOSE_LEVEL
66 #ifndef STXXL_VERBOSE_LEVEL
67 #define STXXL_VERBOSE_LEVEL -1
71 #if STXXL_VERBOSE_LEVEL > -10
72 #define STXXL_MSG(x) _STXXL_PRINT("STXXL-MSG", x, _STXXL_PRINT_FLAGS_DEFAULT)
75 #define STXXL_MSG(x) _STXXL_NOT_VERBOSE
78 #if STXXL_VERBOSE_LEVEL > -100
79 #define STXXL_ERRMSG(x) _STXXL_PRINT("STXXL-ERRMSG", x, _STXXL_PRINT_FLAGS_ERROR)
82 #define STXXL_ERRMSG(x) _STXXL_NOT_VERBOSE
90 #if STXXL_VERBOSE_LEVEL > -1
91 #define STXXL_VERBOSE0(x) _STXXL_PRINT("STXXL-VERBOSE0", x, _STXXL_PRINT_FLAGS_VERBOSE)
93 #define STXXL_VERBOSE0(x) _STXXL_NOT_VERBOSE
96 #if STXXL_VERBOSE_LEVEL > 0
97 #define STXXL_VERBOSE1(x) _STXXL_PRINT("STXXL-VERBOSE1", x, _STXXL_PRINT_FLAGS_VERBOSE)
99 #define STXXL_VERBOSE1(x) _STXXL_NOT_VERBOSE
102 #define STXXL_VERBOSE(x) STXXL_VERBOSE1(x)
104 #if STXXL_VERBOSE_LEVEL > 1
105 #define STXXL_VERBOSE2(x) _STXXL_PRINT("STXXL-VERBOSE2", x, _STXXL_PRINT_FLAGS_VERBOSE)
107 #define STXXL_VERBOSE2(x) _STXXL_NOT_VERBOSE
110 #if STXXL_VERBOSE_LEVEL > 2
111 #define STXXL_VERBOSE3(x) _STXXL_PRINT("STXXL-VERBOSE3", x, _STXXL_PRINT_FLAGS_VERBOSE)
113 #define STXXL_VERBOSE3(x) _STXXL_NOT_VERBOSE
121 #define STXXL_CHECK(condition) \
123 if (!(condition)) { \
124 _STXXL_PRINT("STXXL-CHECK", \
125 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
126 _STXXL_PRINT_FLAGS_ERROR); abort(); \
130 #define STXXL_CHECK2(condition, text) \
132 if (!(condition)) { \
133 _STXXL_PRINT("STXXL-CHECK", \
134 text << " - " #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
135 _STXXL_PRINT_FLAGS_ERROR); abort(); \
145 #define STXXL_ASSERT(condition) \
147 if (!(condition)) { \
148 _STXXL_PRINT("STXXL-ASSERT", \
149 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
150 _STXXL_PRINT_FLAGS_ERROR); abort(); \
157 #define STXXL_ASSERT(condition) \
159 if (!(condition)) { \
160 _STXXL_PRINT("STXXL-ASSERT", \
161 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
162 _STXXL_PRINT_FLAGS_ERROR); abort(); \
172 #define STXXL_CHECK_THROW(code, exception_type) \
174 bool t_ = false; try { code; } \
175 catch (const exception_type&) { t_ = true; } \
177 _STXXL_PRINT("STXXL-CHECK-THROW", \
178 #code " - NO EXCEPTION " #exception_type \
179 " @ " __FILE__ ":" << __LINE__, \
180 _STXXL_PRINT_FLAGS_ERROR); \
186 #endif // !STXXL_VERBOSE_HEADER
#define STXXL_BEGIN_NAMESPACE
void print_msg(const char *label, const std::string &msg, unsigned flags)
#define STXXL_END_NAMESPACE