Browse Source

fixed debug macros

main
Stefan Pranger 3 years ago
parent
commit
cd93c42cf0
  1. 26
      io/debug.h

26
io/debug.h

@ -3,19 +3,25 @@
#include <iostream>
#include <string>
struct X {
#ifdef LOG_DEBUG
X() { if(false) std::cout.setstate(std::ios_base::failbit); }
~X() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
#else
X() { std::cout.setstate(std::ios_base::failbit); }
~X() { std::cout.clear(); }
#endif
struct print {
print() { if(false) std::cout.setstate(std::ios_base::failbit); }
~print() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
};
struct noprint {
noprint() { if(true) std::cout.setstate(std::ios_base::failbit); }
~noprint() { if(true) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
};
#define DEBUG (X(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
#define WARN (X(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
#ifdef LOG_DEBUG
#define DEBUG (print(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
#define WARN (print(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
#else
#define DEBUG (noprint(), std::cout << "")
#define WARN (noprint(), std::cout << "")
#endif
#ifdef LOG_DEBUG
#define STEP \

Loading…
Cancel
Save