Skip to main content

The AutoTrace Class Reference

Helper class to trace an entry statement at creation and another one at destruction. More...

Declaration

class AutoTrace { ... }

Included Headers

#include <src/trace.h>

Public Constructors Index

AutoTrace (spdlog::source_loc loc)
template <typename... Args>
AutoTrace (spdlog::source_loc loc, const std::string &fmt, Args &&...args)

Public Destructor Index

~AutoTrace ()

Public Member Functions Index

template <typename... Args>
voidadd (spdlog::source_loc loc, const std::string &fmt, Args &&...args)
template <typename... Args>
voidsetExit (spdlog::source_loc loc, const std::string &msg, Args &&...args)

Private Member Attributes Index

spdlog::source_locm_loc
std::stringm_exitMessage

Description

Helper class to trace an entry statement at creation and another one at destruction.

Definition at line 81 of file trace.h.

Public Constructors

AutoTrace()

AutoTrace::AutoTrace (spdlog::source_loc loc)
inline explicit

Definition at line 84 of file trace.h.

84 explicit AutoTrace(spdlog::source_loc loc) : m_loc(loc)
85 {
86 if (g_tracer)
87 {
88 g_tracer->log(m_loc,spdlog::level::trace,">");
89 }
90 }

References g_tracer and m_loc.

AutoTrace()

template <typename... Args>
AutoTrace::AutoTrace (spdlog::source_loc loc, const std::string & fmt, Args &&... args)
inline explicit

Definition at line 92 of file trace.h.

92 explicit AutoTrace(spdlog::source_loc loc,
93 const std::string &fmt, Args&&...args) : m_loc(loc)
94 {
95 if (g_tracer)
96 {
97 if (fmt.empty())
98 {
99 g_tracer->log(m_loc,spdlog::level::trace,">");
100 }
101 else
102 {
103 g_tracer->log(m_loc,spdlog::level::trace,fmt::runtime("> "+fmt),std::forward<Args>(args)...);
104 }
105 }
106 }

References g_tracer and m_loc.

Public Destructor

~AutoTrace()

AutoTrace::~AutoTrace ()
inline

Definition at line 107 of file trace.h.

108 {
109 if (g_tracer)
110 {
111 if (m_exitMessage.empty())
112 {
113 g_tracer->log(m_loc,spdlog::level::trace,"<");
114 }
115 else
116 {
117 g_tracer->log(m_loc,spdlog::level::trace,"< "+m_exitMessage);
118 }
119 }
120 }

References g_tracer, m_exitMessage and m_loc.

Public Member Functions

add()

template <typename... Args>
void AutoTrace::add (spdlog::source_loc loc, const std::string & fmt, Args &&... args)
inline

Definition at line 124 of file trace.h.

124 void add(spdlog::source_loc loc,
125 const std::string &fmt, Args&&...args)
126 {
127 if (g_tracer)
128 {
129 g_tracer->log(loc,spdlog::level::trace,fmt::runtime(": "+fmt),std::forward<Args>(args)...);
130 }
131 }

Reference g_tracer.

setExit()

template <typename... Args>
void AutoTrace::setExit (spdlog::source_loc loc, const std::string & msg, Args &&... args)
inline

Definition at line 133 of file trace.h.

133 void setExit(spdlog::source_loc loc,
134 const std::string &msg,Args&&...args)
135 {
136 m_loc = loc;
137 m_exitMessage = fmt::format(fmt::runtime(msg),std::forward<Args>(args)...);
138 }

References m_exitMessage, m_loc and msg.

Private Member Attributes

m_exitMessage

std::string AutoTrace::m_exitMessage

Definition at line 141 of file trace.h.

141 std::string m_exitMessage;

Referenced by setExit and ~AutoTrace.

m_loc

spdlog::source_loc AutoTrace::m_loc

Definition at line 140 of file trace.h.

140 spdlog::source_loc m_loc;

Referenced by AutoTrace, AutoTrace, setExit and ~AutoTrace.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.