From a6b23a751efabb099e6c6c4a8780d43f17f2eabe Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 4 May 2023 20:56:50 -0400 Subject: [PATCH] Add env var to force logging on msw (cherry picked from commit 18dd6231222923297b9f13e3a55e0ea54c88fce5) --- libs/kiplatform/msw/app.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/kiplatform/msw/app.cpp b/libs/kiplatform/msw/app.cpp index dc45442efa..82cace000c 100644 --- a/libs/kiplatform/msw/app.cpp +++ b/libs/kiplatform/msw/app.cpp @@ -67,6 +67,8 @@ bool KIPLATFORM::APP::Init() { #if !defined( __MINGW32__ ) // These redirections create problems on mingw: // Nothing is printed to the console + + if( GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE ) { freopen( "CONIN$", "r", stdin ); @@ -96,6 +98,18 @@ bool KIPLATFORM::APP::Init() std::cin.clear(); } + // It may be useful to log up to traces in a console, but in Release builds the log level changes to Info + // Also we have to force the active target to stderr or else it goes to the void + bool forceLog = wxGetEnv( wxS( "KICAD_FORCE_CONSOLE_TRACE" ), nullptr ); + if( forceLog ) + { + wxLog::EnableLogging( true ); +#ifndef DEBUG + wxLog::SetLogLevel( wxLOG_Trace ); +#endif; + wxLog::SetActiveTarget( new wxLogStderr ); + } + return true; }