15 #ifndef STXXL_VERBOSE_HEADER
16 #define STXXL_VERBOSE_HEADER
24 #define _STXXL_PRNT_COUT (1 << 0)
25 #define _STXXL_PRNT_CERR (1 << 1)
26 #define _STXXL_PRNT_LOG (1 << 2)
27 #define _STXXL_PRNT_ERRLOG (1 << 3)
28 #define _STXXL_PRNT_ADDNEWLINE (1 << 16)
29 #define _STXXL_PRNT_TIMESTAMP (1 << 17)
30 #define _STXXL_PRNT_THREAD_ID (1 << 18)
32 #define _STXXL_PRINT_FLAGS_DEFAULT (_STXXL_PRNT_COUT | _STXXL_PRNT_LOG)
33 #define _STXXL_PRINT_FLAGS_ERROR (_STXXL_PRNT_CERR | _STXXL_PRNT_ERRLOG)
34 #define _STXXL_PRINT_FLAGS_VERBOSE (_STXXL_PRINT_FLAGS_DEFAULT | _STXXL_PRNT_TIMESTAMP | _STXXL_PRNT_THREAD_ID)
38 void print_msg(
const char* label,
const std::string& msg,
unsigned flags);
42 #define _STXXL_PRINT(label, message, flags) \
44 std::ostringstream str_; \
46 stxxl::print_msg(label, str_.str(), flags | _STXXL_PRNT_ADDNEWLINE); \
49 #define _STXXL_NOT_VERBOSE(message) \
52 std::ostringstream str_; \
57 #ifdef STXXL_FORCE_VERBOSE_LEVEL
58 #undef STXXL_VERBOSE_LEVEL
59 #define STXXL_VERBOSE_LEVEL STXXL_FORCE_VERBOSE_LEVEL
62 #ifdef STXXL_DEFAULT_VERBOSE_LEVEL
63 #ifndef STXXL_VERBOSE_LEVEL
64 #define STXXL_VERBOSE_LEVEL STXXL_DEFAULT_VERBOSE_LEVEL
68 #ifndef STXXL_VERBOSE_LEVEL
69 #define STXXL_VERBOSE_LEVEL -1
72 #if STXXL_VERBOSE_LEVEL > -10
73 #define STXXL_MSG(x) _STXXL_PRINT("STXXL-MSG", x, _STXXL_PRINT_FLAGS_DEFAULT)
76 #define STXXL_MSG(x) _STXXL_NOT_VERBOSE(x)
80 #if STXXL_VERBOSE_LEVEL > -10
81 #define STXXL_VARDUMP(x) _STXXL_PRINT("STXXL-MSG", #x " = " << x, _STXXL_PRINT_FLAGS_DEFAULT)
83 #define STXXL_VARDUMP(x) _STXXL_NOT_VERBOSE
87 #if STXXL_VERBOSE_LEVEL > -10
88 #define STXXL_MEMDUMP(x) _STXXL_PRINT("STXXL-MSG", #x " = " << stxxl::format_IEC_size(x) << "B", _STXXL_PRINT_FLAGS_DEFAULT)
90 #define STXXL_MEMDUMP(x) _STXXL_NOT_VERBOSE
93 #if STXXL_VERBOSE_LEVEL > -100
94 #define STXXL_ERRMSG(x) _STXXL_PRINT("STXXL-ERRMSG", x, _STXXL_PRINT_FLAGS_ERROR)
97 #define STXXL_ERRMSG(x) _STXXL_NOT_VERBOSE(x)
104 #if STXXL_VERBOSE_LEVEL > -1
105 #define STXXL_VERBOSE0(x) _STXXL_PRINT("STXXL-VERBOSE0", x, _STXXL_PRINT_FLAGS_VERBOSE)
107 #define STXXL_VERBOSE0(x) _STXXL_NOT_VERBOSE(x)
110 #if STXXL_VERBOSE_LEVEL > 0
111 #define STXXL_VERBOSE1(x) _STXXL_PRINT("STXXL-VERBOSE1", x, _STXXL_PRINT_FLAGS_VERBOSE)
113 #define STXXL_VERBOSE1(x) _STXXL_NOT_VERBOSE(x)
116 #define STXXL_VERBOSE(x) STXXL_VERBOSE1(x)
118 #if STXXL_VERBOSE_LEVEL > 1
119 #define STXXL_VERBOSE2(x) _STXXL_PRINT("STXXL-VERBOSE2", x, _STXXL_PRINT_FLAGS_VERBOSE)
121 #define STXXL_VERBOSE2(x) _STXXL_NOT_VERBOSE(x)
124 #if STXXL_VERBOSE_LEVEL > 2
125 #define STXXL_VERBOSE3(x) _STXXL_PRINT("STXXL-VERBOSE3", x, _STXXL_PRINT_FLAGS_VERBOSE)
127 #define STXXL_VERBOSE3(x) _STXXL_NOT_VERBOSE(x)
133 #define STXXL_VERBOSE0_THIS(x) \
134 STXXL_VERBOSE0("[" << static_cast<void*>(this) << "] " << x)
136 #define STXXL_VERBOSE1_THIS(x) \
137 STXXL_VERBOSE1("[" << static_cast<void*>(this) << "] " << x)
139 #define STXXL_VERBOSE2_THIS(x) \
140 STXXL_VERBOSE2("[" << static_cast<void*>(this) << "] " << x)
142 #define STXXL_VERBOSE3_THIS(x) \
143 STXXL_VERBOSE3("[" << static_cast<void*>(this) << "] " << x)
147 #define STXXL_DEBUG_COND(dbg, x) \
150 _STXXL_PRINT("STXXL-DEBUG", x, _STXXL_PRINT_FLAGS_DEFAULT); \
156 #define STXXL_DEBUG(x) STXXL_DEBUG_COND(debug, x)
160 #define STXXL_DEBUG0(x) STXXL_DEBUG_COND(false, x)
164 #define STXXL_DEBUG1(x) STXXL_DEBUG_COND(true, x)
170 #define STXXL_CHECK(condition) \
172 if (!(condition)) { \
173 _STXXL_PRINT("STXXL-CHECK", \
174 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
175 _STXXL_PRINT_FLAGS_ERROR); abort(); \
179 #define STXXL_CHECK2(condition, text) \
181 if (!(condition)) { \
182 _STXXL_PRINT("STXXL-CHECK", \
183 text << " - " #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
184 _STXXL_PRINT_FLAGS_ERROR); abort(); \
192 #define STXXL_CHECK_EQUAL(a, b) \
195 _STXXL_PRINT("STXXL-CHECK", \
196 "\"" << a << "\" = " #a " == " #b " = \"" << b << "\"" \
197 " - FAILED @ " __FILE__ ":" << __LINE__, \
198 _STXXL_PRINT_FLAGS_ERROR); abort(); \
208 #define STXXL_ASSERT(condition) \
210 if (!(condition)) { \
211 _STXXL_PRINT("STXXL-ASSERT", \
212 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
213 _STXXL_PRINT_FLAGS_ERROR); abort(); \
220 #define STXXL_ASSERT(condition) \
222 if (!(condition)) { \
223 _STXXL_PRINT("STXXL-ASSERT", \
224 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
225 _STXXL_PRINT_FLAGS_ERROR); abort(); \
236 #if STXXL_DEBUG_ASSERTIONS
238 #define STXXL_DEBUG_ASSERT(condition) \
240 if (!(condition)) { \
241 _STXXL_PRINT("STXXL-DEBUG-ASSERT", \
242 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
243 _STXXL_PRINT_FLAGS_ERROR); abort(); \
250 #define STXXL_DEBUG_ASSERT(condition) \
252 if (!(condition)) { \
253 _STXXL_PRINT("STXXL-DEBUG-ASSERT", \
254 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
255 _STXXL_PRINT_FLAGS_ERROR); abort(); \
265 #define STXXL_CHECK_THROW(code, exception_type) \
267 bool t_ = false; try { code; } \
268 catch (const exception_type&) { t_ = true; } \
270 _STXXL_PRINT("STXXL-CHECK-THROW", \
271 #code " - NO EXCEPTION " #exception_type \
272 " @ " __FILE__ ":" << __LINE__, \
273 _STXXL_PRINT_FLAGS_ERROR); \
279 #endif // !STXXL_VERBOSE_HEADER
#define STXXL_BEGIN_NAMESPACE
void print_msg(const char *label, const std::string &msg, unsigned flags)
#define STXXL_END_NAMESPACE