kopia lustrzana https://gitlab.com/tomaszg/geostat
Fix debug so that multithreaded output doesn't overlap (not needed here, just for consistency with other projects)
rodzic
dcaa8fbf71
commit
59d8b7007c
|
@ -10,7 +10,7 @@ Debug::Debug(int n) : lvl(n) {
|
|||
|
||||
indent.append(lvl - 1, '\t');
|
||||
if (lvl > 1) indent.append("*** ");
|
||||
std::cerr << indent;
|
||||
buffer << indent;
|
||||
|
||||
// std::time_t now = std::time(nullptr);
|
||||
// std::string dt = std::ctime(&now);
|
||||
|
@ -19,7 +19,7 @@ Debug::Debug(int n) : lvl(n) {
|
|||
}
|
||||
|
||||
Debug::~Debug() {
|
||||
if (lvl <= debug_level) std::cerr << '\n';
|
||||
if (lvl <= debug_level) std::cerr << buffer.str() << '\n';
|
||||
}
|
||||
|
||||
void Debug::set_debug_level(int n) { debug_level = n; }
|
||||
|
|
3
debug.h
3
debug.h
|
@ -8,6 +8,7 @@ class Debug {
|
|||
private:
|
||||
int lvl; // debug level of the particular instance of Debug stream
|
||||
static int debug_level; // debug level set globally
|
||||
std::stringstream buffer;
|
||||
|
||||
public:
|
||||
explicit Debug(int n);
|
||||
|
@ -20,7 +21,7 @@ public:
|
|||
template <typename T>
|
||||
Debug& operator<<(T const& value) {
|
||||
if (lvl <= debug_level)
|
||||
std::cout << value;
|
||||
buffer << value;
|
||||
return *this;
|
||||
}
|
||||
static void set_debug_level(int n);
|
||||
|
|
Ładowanie…
Reference in New Issue