Class for debugging output.
Use DEBUGTRACE_FUNCTION at the start of a function to have trace output at the start and at the return from the function with the name of that function. Indentation is increased to indicate call stack.
Use DEBUGTRACE with an argument containing stream operations to output any debugging information as desired.
Use DEBUGTRACE_ENABLE to enable the trace output at run-time. By default, the trace output is disabled.
Define the macro "DEBUG_NO_TRACE" to completely disable tracing in the library and applications, which can be used to improve performance if no tracing is desired.
Generally speaking, the class should not be used directly, instead use the macros described above.
Definition at line 75 of file DebugTrace.hpp.
#include <DebugTrace.hpp>
Public Member Functions | |
DebugTrace (const std::string funcName) | |
~DebugTrace () | |
Static Public Member Functions | |
static void | trace (const std::string &s) |
If enabled is true, print s to stderr. More... | |
Static Public Attributes | |
static GNSSTK_EXPORT std::atomic< bool > | enabled |
If true, debugging/trace output will be printed to stderr. More... | |
Private Attributes | |
std::string | functionName |
Static Private Attributes | |
static std::atomic< unsigned > | indent |
How many spaces to indent the trace output. More... | |
gnsstk::DebugTrace::DebugTrace | ( | const std::string | funcName | ) |
Start a function trace by printing the function name and indenting.
[in] | funcName | the name of the function to print when entering and leaving. |
Definition at line 49 of file DebugTrace.cpp.
gnsstk::DebugTrace::~DebugTrace | ( | ) |
Definition at line 59 of file DebugTrace.cpp.
|
static |
If enabled is true, print s
to stderr.
Definition at line 68 of file DebugTrace.cpp.
|
static |
If true, debugging/trace output will be printed to stderr.
Definition at line 86 of file DebugTrace.hpp.
|
private |
Save the name of the function so that the destructor knows what to print.
Definition at line 90 of file DebugTrace.hpp.
|
staticprivate |
How many spaces to indent the trace output.
Definition at line 92 of file DebugTrace.hpp.