KiCad PCB EDA Suite
trace_helpers.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef _TRACE_HELPERS_H_
31#define _TRACE_HELPERS_H_
32
33#include <wx/arrstr.h>
34#include <wx/event.h>
35#include <wx/string.h>
36
37#include <stdarg.h>
38#include <map>
39
52
58extern const wxChar* const traceFindItem;
59
65extern const wxChar* const traceFindReplace;
66
72extern const wxChar* const kicadTraceCoords;
73
79extern const wxChar* const kicadTraceKeyEvent;
80
86extern const wxChar* const kicadTraceToolStack;
87
93extern const wxChar* const kicadTraceCoroutineStack;
94
100extern const wxChar* const traceAutoSave;
101
107extern const wxChar* const traceSchLibMem;
108
114extern const wxChar* const traceSchLegacyPlugin;
115
121extern const wxChar* const traceKicadPcbPlugin;
122
128extern const wxChar* const traceGedaPcbPlugin;
129
135extern const wxChar* const tracePrinting;
136
142extern const wxChar* const tracePathsAndFiles;
143
149extern const wxChar* const traceLocale;
150
156extern const wxChar* const traceFonts;
157
163extern const wxChar* const traceScreen;
164
170extern const wxChar* const traceDisplayLocation;
171
178extern const wxChar* const traceZoomScroll;
179
185extern const wxChar* const traceSymbolResolver;
186
192extern const wxChar* const traceSchSheetPaths;
193
199extern const wxChar* const traceEnvVars;
200
206extern const wxChar* const traceGalProfile;
207
213extern const wxChar* const traceKiCad2Step;
214
216
223extern wxString dump( const wxKeyEvent& aEvent );
224
231extern wxString dump( const wxArrayString& aArray );
232
234{
235public:
237 m_globalTraceEnabled( false ),
238 m_printAllTraces (false )
239 {};
241
242 static TRACE_MANAGER& Instance();
243
244 WX_DEFINE_VARARG_FUNC_VOID( Trace, 2, (const wxString, const wxFormatString&), DoTrace,
245 DoTraceUtf8 )
246
247 void DoTrace( const wxString aWhat, const wxChar* aFmt, ... )
248 {
249 va_list argptr;
250 va_start( argptr, aFmt );
251 traceV( aWhat, aFmt, argptr );
252 va_end( argptr );
253 }
254
255#if wxUSE_UNICODE_UTF8
256 void DoTraceUtf8( const wxString aWhat, const wxChar* aFmt, ... )
257 {
258 va_list argptr;
259 va_start( argptr, aFmt );
260 traceV( aWhat, aFmt, argptr );
261 va_end( argptr );
262 }
263#endif
264
265 bool IsTraceEnabled( const wxString& aWhat );
266
267private:
268 void traceV( const wxString& aWhat, const wxString& aFmt, va_list vargs );
269 void init();
270
271 std::map<wxString, bool> m_enabledTraces;
274};
275
276#define KI_TRACE( aWhat, ... ) \
277 if( TRACE_MANAGER::Instance().IsTraceEnabled( aWhat ) ) \
278 { \
279 TRACE_MANAGER::Instance().Trace( aWhat, __VA_ARGS__ ); \
280 } \
281 else \
282 { \
283 }
284
285#endif // _TRACE_HELPERS_H_
static TRACE_MANAGER & Instance()
const wxChar * aFmt
va_end(argptr)
traceV(aWhat, aFmt, argptr)
const wxChar va_start(argptr, aFmt)
bool IsTraceEnabled(const wxString &aWhat)
WX_DEFINE_VARARG_FUNC_VOID(Trace, 2,(const wxString, const wxFormatString &), DoTrace, DoTraceUtf8) void DoTrace(const wxString aWhat
bool m_globalTraceEnabled
std::map< wxString, bool > m_enabledTraces
const wxChar *const traceScreen
Flag to enable debug output of BASE_SCREEN and it's derivatives.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
const wxChar *const tracePrinting
Flag to enable print controller debug output.
const wxChar *const traceFindItem
Flag to enable find debug tracing.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
const wxChar *const kicadTraceCoroutineStack
Flag to enable tracing of the coroutine call stack.
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
const wxChar *const traceSchLibMem
Flag to enable schematic library memory deletion debug output.
const wxChar *const traceFonts
Flag to enable locale debug output.
const wxChar *const traceSymbolResolver
Flag to enable debug output of symbol library resolver results.
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
const wxChar *const traceLocale
Flag to enable locale debug output.
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
const wxChar *const traceGedaPcbPlugin
Flag to enable GEDA PCB plugin debug output.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
wxString dump(const wxKeyEvent &aEvent)
Debug helper for printing wxKeyEvent information.