tlx
|
LOG and sLOG for development and debugging. More...
#include <core.hpp>
Public Member Functions | |
Logger () | |
construction: add prefix if desired More... | |
template<typename AnyType > | |
Logger & | operator<< (const AnyType &at) |
output any type, including io manipulators More... | |
~Logger () | |
destructor: output a newline More... | |
Private Attributes | |
std::ostringstream | oss_ |
collector stream More... | |
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.
|
inline |