KiCad PCB EDA Suite
TRACE_MANAGER Class Reference

#include <trace_helpers.h>

Public Member Functions

 TRACE_MANAGER ()
 
 ~TRACE_MANAGER ()
 
 WX_DEFINE_VARARG_FUNC_VOID (Trace, 2,(const wxString, const wxFormatString &), DoTrace, DoTraceUtf8) void DoTrace(const wxString aWhat
 
const wxChar va_start (argptr, aFmt)
 
 traceV (aWhat, aFmt, argptr)
 
 va_end (argptr)
 
bool IsTraceEnabled (const wxString &aWhat)
 

Static Public Member Functions

static TRACE_MANAGERInstance ()
 

Public Attributes

const wxChar * aFmt
 

Private Member Functions

void traceV (const wxString &aWhat, const wxString &aFmt, va_list vargs)
 
void init ()
 

Private Attributes

std::map< wxString, bool > m_enabledTraces
 
bool m_globalTraceEnabled
 
bool m_printAllTraces
 

Detailed Description

Definition at line 226 of file trace_helpers.h.

Constructor & Destructor Documentation

◆ TRACE_MANAGER()

TRACE_MANAGER::TRACE_MANAGER ( )
inline

Definition at line 229 of file trace_helpers.h.

229 :
230 m_globalTraceEnabled( false ),
231 m_printAllTraces (false )
232 {};
bool m_globalTraceEnabled

Referenced by Instance().

◆ ~TRACE_MANAGER()

TRACE_MANAGER::~TRACE_MANAGER ( )
inline

Definition at line 233 of file trace_helpers.h.

233{};

Member Function Documentation

◆ init()

void TRACE_MANAGER::init ( )
private

Definition at line 325 of file trace_helpers.cpp.

326{
327 wxString traceVars;
328 m_globalTraceEnabled = wxGetEnv( wxT( "KICAD_TRACE" ), &traceVars );
329 m_printAllTraces = false;
330
332 return;
333
334 wxStringTokenizer tokenizer( traceVars, wxT( "," ) );
335
336 while( tokenizer.HasMoreTokens() )
337 {
338 wxString token = tokenizer.GetNextToken();
339 m_enabledTraces[token] = true;
340
341 if( token.Lower() == wxT( "all" ) )
342 m_printAllTraces = true;
343 }
344}
std::map< wxString, bool > m_enabledTraces

References m_enabledTraces, m_globalTraceEnabled, and m_printAllTraces.

Referenced by Instance().

◆ Instance()

TRACE_MANAGER & TRACE_MANAGER::Instance ( )
static

Definition at line 282 of file trace_helpers.cpp.

283{
284 static TRACE_MANAGER* self = nullptr;
285
286 if( !self )
287 {
288 self = new TRACE_MANAGER;
289 self->init();
290 }
291
292 return *self;
293}

References init(), and TRACE_MANAGER().

◆ IsTraceEnabled()

bool TRACE_MANAGER::IsTraceEnabled ( const wxString &  aWhat)

Definition at line 296 of file trace_helpers.cpp.

297{
298 if( !m_printAllTraces )
299 {
301 return false;
302
303 if( m_enabledTraces.find( aWhat ) == m_enabledTraces.end() )
304 return false;
305 }
306
307 return true;
308}

References m_enabledTraces, m_globalTraceEnabled, and m_printAllTraces.

Referenced by traceV().

◆ traceV() [1/2]

TRACE_MANAGER::traceV ( aWhat  ,
aFmt  ,
argptr   
)

◆ traceV() [2/2]

void TRACE_MANAGER::traceV ( const wxString &  aWhat,
const wxString &  aFmt,
va_list  vargs 
)
private

Definition at line 311 of file trace_helpers.cpp.

312{
313 if( !IsTraceEnabled( aWhat ) )
314 return;
315
316 wxString str;
317 str.PrintfV( aFmt, vargs );
318
319#ifdef __unix__
320 fprintf( stderr, " %-30s | %s", aWhat.c_str().AsChar(), str.c_str().AsChar() );
321#endif
322}
const wxChar * aFmt
bool IsTraceEnabled(const wxString &aWhat)

References aFmt, and IsTraceEnabled().

◆ va_end()

TRACE_MANAGER::va_end ( argptr  )

◆ va_start()

const wxChar TRACE_MANAGER::va_start ( argptr  ,
aFmt   
)

◆ WX_DEFINE_VARARG_FUNC_VOID()

TRACE_MANAGER::WX_DEFINE_VARARG_FUNC_VOID ( Trace  ,
,
(const wxString, const wxFormatString &)  ,
DoTrace  ,
DoTraceUtf8   
) const

Member Data Documentation

◆ aFmt

const wxChar* TRACE_MANAGER::aFmt

Definition at line 240 of file trace_helpers.h.

Referenced by traceV().

◆ m_enabledTraces

std::map<wxString, bool> TRACE_MANAGER::m_enabledTraces
private

Definition at line 264 of file trace_helpers.h.

Referenced by init(), and IsTraceEnabled().

◆ m_globalTraceEnabled

bool TRACE_MANAGER::m_globalTraceEnabled
private

Definition at line 265 of file trace_helpers.h.

Referenced by init(), and IsTraceEnabled().

◆ m_printAllTraces

bool TRACE_MANAGER::m_printAllTraces
private

Definition at line 266 of file trace_helpers.h.

Referenced by init(), and IsTraceEnabled().


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