Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
gnsstk::DebugTrace Class Reference

Detailed Description

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.

Note
Although a mutex is used to serialize access to the indent data member, no attempt is currently made to differentiate indentation levels across multiple threads. As such, the indentation may get confusing in a multi-thread application.

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...
 

Constructor & Destructor Documentation

◆ DebugTrace()

gnsstk::DebugTrace::DebugTrace ( const std::string  funcName)

Start a function trace by printing the function name and indenting.

Parameters
[in]funcNamethe name of the function to print when entering and leaving.

Definition at line 49 of file DebugTrace.cpp.

◆ ~DebugTrace()

gnsstk::DebugTrace::~DebugTrace ( )

Definition at line 59 of file DebugTrace.cpp.

Member Function Documentation

◆ trace()

void gnsstk::DebugTrace::trace ( const std::string &  s)
static

If enabled is true, print s to stderr.

Definition at line 68 of file DebugTrace.cpp.

Member Data Documentation

◆ enabled

std::atomic< bool > gnsstk::DebugTrace::enabled
static

If true, debugging/trace output will be printed to stderr.

Definition at line 86 of file DebugTrace.hpp.

◆ functionName

std::string gnsstk::DebugTrace::functionName
private

Save the name of the function so that the destructor knows what to print.

Definition at line 90 of file DebugTrace.hpp.

◆ indent

std::atomic< unsigned > gnsstk::DebugTrace::indent
staticprivate

How many spaces to indent the trace output.

Definition at line 92 of file DebugTrace.hpp.


The documentation for this class was generated from the following files:


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44