Thrill
0.1
|
LOG and sLOG for development and debugging.
This is a short description of how to use LOG and sLOG for rapid development of modules with debug output, and how to keep it afterwards.
There are two classes Logger and SpacingLogger, but one does not use these directly.
Instead there are the macros: LOG and sLOG that can be used as such:
There macros only print the lines if the boolean variable debug is true. This variable is searched for in the scope of the LOG, which means it can be set or overridden in the function scope, the class scope, from inherited classes, or even the global scope.
There are two variation of LOG and sLOG : append 0 or 1 for temporarily disabled or enabled debug lines. These macros are then LOG0, LOG1, sLOG0, and sLOG1. The suffix overrides the debug variable's setting.
After a module works as intended, one can just set debug = false
, and all debug output will disappear and be optimized out.
#include <core.hpp>
Public Member Functions | |
Logger () | |
construction: add prefix if desired More... | |
~Logger () | |
destructor: output a newline More... | |
template<typename AnyType > | |
Logger & | operator<< (const AnyType &at) |
output any type, including io manipulators More... | |
Private Attributes | |
std::ostringstream | oss_ |
collector stream More... | |
Logger | ( | ) |
construction: add prefix if desired
Definition at line 86 of file core.cpp.
References LoggerPrefixHook::add_log_prefix(), and tlx::s_logger_prefix_hook.
~Logger | ( | ) |
destructor: output a newline
Definition at line 92 of file core.cpp.
Referenced by Logger::operator<<().
|
inline |
output any type, including io manipulators
Definition at line 90 of file core.hpp.
References Logger::~Logger().