You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
765 B

  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. struct X {
  5. #ifdef LOG_DEBUG
  6. X() { if(false) std::cout.setstate(std::ios_base::failbit); }
  7. ~X() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } }
  8. #else
  9. X() { std::cout.setstate(std::ios_base::failbit); }
  10. ~X() { std::cout.clear(); }
  11. #endif
  12. };
  13. #define DEBUG (X(), std::cout << "DEBUG[" << __FILE__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
  14. #define WARN (X(), std::cout << "WARN [" << __FILE__ << ":" << __LINE__ << " in " << __func__ << "()]: ")
  15. #ifdef LOG_DEBUG
  16. #define STEP \
  17. do { DEBUG << "Stepping through, Hit Enter..."; \
  18. std::cin.get(); \
  19. } while (0)
  20. #else
  21. #define STEP (void)(0)
  22. #endif
  23. namespace io {
  24. void debug(std::string msg);
  25. }