Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Stroika::Foundation::Debug::TraceContextBumper Class Referencefinal

#include <Trace.h>

Public Member Functions

 TraceContextBumper () noexcept
 
template<typename CHAR_T , Private_::IFormatLiteral_ FORMAT_LITERAL, typename... ARGS>
requires (same_as<CHAR_T, char> or same_as<CHAR_T, wchar_t>)
 TraceContextBumper (const CHAR_T *contextName, const FORMAT_LITERAL &fmt, ARGS &&... args) noexcept
 fmt "..."_f: args checked at compile time
 

Detailed Description

Define a new start/end context (with optional label) for trace messages emitted with DbgTrace (), and indent future DbgTrace () messages (from this thread) during the lifetime of TraceContextBumper.

Example Usage
Debug::TraceContextBumper ctx{"MyXercesMemMgr_::DUMPCurMemStats"};
DbgTrace (L"x");
#define DbgTrace
Definition Trace.h:327

Generates log output: <MyXercesMemMgr_::DUMPCurMemStats> x </MyXercesMemMgr_::DUMPCurMemStats>

Example Usage
Debug::TraceContextBumper ctx{"OptionsFile::ReadRaw", "readfilename={}"_f, GetReadFilePath_ ()};

Generates log output (assuming ReadRaw is quick and doesn't do more DbgTrace calls): <OptionsFile::ReadRaw (readfilename=C:\Users\Lewis\AppData\Local\Temp\MyModule.json)/>

Example Usage
Debug::TraceContextBumper ctx { Stroika_Foundation_Debug_OptionalizeTraceArgs ("OptionsFile::ReadRaw", "readfilename={}"_f, GetReadFilePath_ ().c_str ()) };
DbgTrace (L"x");
#define Stroika_Foundation_Debug_OptionalizeTraceArgs(...)
Definition Trace.h:288

Generates log output: <OptionsFile::ReadRaw (readfilename=C:\Users\Lewis\AppData\Local\Temp\MyModule.json)> x </OptionsFile::ReadRaw>

Example Usage
struct X {
// ... lots of data members - and you get a crash between constructor or destruction of some of them
// ... use this trick to see dbgmessages BETWEEN construction and destruction of each member
ComplexObject fComplexObject1;
TraceContextBumper tmpNoteAfterComplexObj1 {"after fComplexObject1"};
ComplexObject fComplexObject2;
TraceContextBumper tmpNoteAfterComplexObj2 {"after fComplexObject2"};
};
Note
Not Cancelation Point - and uses noexcept
safe to call and does nothing if !qStroika_Foundation_Debug_DefaultTracingOn

Definition at line 164 of file Trace.h.

Constructor & Destructor Documentation

◆ TraceContextBumper()

Stroika::Foundation::Debug::TraceContextBumper::TraceContextBumper ( )
noexcept

If constructor taking const char* used, the argument must be ASCII characters.

The constructor with 'extraFmt', emits the extra data in the heading of the trace message, but not the close brace. This can allow for more terse TraceContextBumper messages, and more terse calling usage.

For TraceContextBumper (const wchar_t* contextName, const wchar_t* extraFmt, ...) usage,

See also
Stroika_Foundation_Debug_OptionalizeTraceArgs to optionally suppress side-effects.
Note
Not Cancelation Point - and uses noexcept

Definition at line 107 of file Trace.inl.


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