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)
79 #if STXXL_VERBOSE_LEVEL > -100
80 #define STXXL_ERRMSG(x) _STXXL_PRINT("STXXL-ERRMSG", x, _STXXL_PRINT_FLAGS_ERROR)
83 #define STXXL_ERRMSG(x) _STXXL_NOT_VERBOSE(x)
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(x)
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(x)
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(x)
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(x)
119 #define STXXL_VERBOSE0_THIS(x) \
120 STXXL_VERBOSE0("[" << static_cast<void*>(this) << "] " << x)
122 #define STXXL_VERBOSE1_THIS(x) \
123 STXXL_VERBOSE1("[" << static_cast<void*>(this) << "] " << x)
125 #define STXXL_VERBOSE2_THIS(x) \
126 STXXL_VERBOSE2("[" << static_cast<void*>(this) << "] " << x)
128 #define STXXL_VERBOSE3_THIS(x) \
129 STXXL_VERBOSE3("[" << static_cast<void*>(this) << "] " << x)
135 #define STXXL_CHECK(condition) \
137 if (!(condition)) { \
138 _STXXL_PRINT("STXXL-CHECK", \
139 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
140 _STXXL_PRINT_FLAGS_ERROR); abort(); \
144 #define STXXL_CHECK2(condition, text) \
146 if (!(condition)) { \
147 _STXXL_PRINT("STXXL-CHECK", \
148 text << " - " #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
149 _STXXL_PRINT_FLAGS_ERROR); abort(); \
159 #define STXXL_ASSERT(condition) \
161 if (!(condition)) { \
162 _STXXL_PRINT("STXXL-ASSERT", \
163 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
164 _STXXL_PRINT_FLAGS_ERROR); abort(); \
171 #define STXXL_ASSERT(condition) \
173 if (!(condition)) { \
174 _STXXL_PRINT("STXXL-ASSERT", \
175 #condition " - FAILED @ " __FILE__ ":" << __LINE__, \
176 _STXXL_PRINT_FLAGS_ERROR); abort(); \
186 #define STXXL_CHECK_THROW(code, exception_type) \
188 bool t_ = false; try { code; } \
189 catch (const exception_type&) { t_ = true; } \
191 _STXXL_PRINT("STXXL-CHECK-THROW", \
192 #code " - NO EXCEPTION " #exception_type \
193 " @ " __FILE__ ":" << __LINE__, \
194 _STXXL_PRINT_FLAGS_ERROR); \
200 #endif // !STXXL_VERBOSE_HEADER
#define STXXL_BEGIN_NAMESPACE
void print_msg(const char *label, const std::string &msg, unsigned flags)
#define STXXL_END_NAMESPACE