From c743b19e6d784a9cff45c144c643ee072947ee9e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 22 Sep 2015 15:19:44 +0300 Subject: [PATCH 1/2] Make console text to appear in Windows debug output This works in Debug configuration only Color escape sequences are stripped from text before output --- src/win32/i_system.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 372da86856..c21768f1fe 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -1053,6 +1053,30 @@ static TArray bufferedConsoleStuff; void I_PrintStr(const char *cp) { +#ifdef _DEBUG + // Strip out any color escape sequences before writing to debug output + char * copy = new char[strlen(cp)+1]; + const char * srcp = cp; + char * dstp = copy; + + while (*srcp != 0) + { + if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) + { + *dstp++=*srcp++; + } + else + { + if (srcp[1]!=0) srcp+=2; + else break; + } + } + *dstp=0; + + OutputDebugStringA(copy); + delete [] copy; +#endif // _DEBUG + if (ConWindowHidden) { bufferedConsoleStuff.Push(cp); From 37dde2e77d91bcaf257e8c4f4c64fa6fe2607e5f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 23 Sep 2015 10:18:57 +0300 Subject: [PATCH 2/2] Make console to Windows debug output controlled by CVAR DebugView can be used to view output without debugger attached --- src/win32/i_system.cpp | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index c21768f1fe..ef56c7050a 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -137,6 +137,7 @@ extern bool ConWindowHidden; // PUBLIC DATA DEFINITIONS ------------------------------------------------- CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); +CVAR (Bool, con_debugoutput, false, 0); double PerfToSec, PerfToMillisec; UINT TimerPeriod; @@ -1053,29 +1054,30 @@ static TArray bufferedConsoleStuff; void I_PrintStr(const char *cp) { -#ifdef _DEBUG - // Strip out any color escape sequences before writing to debug output - char * copy = new char[strlen(cp)+1]; - const char * srcp = cp; - char * dstp = copy; - - while (*srcp != 0) + if (con_debugoutput) { - if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) - { - *dstp++=*srcp++; - } - else - { - if (srcp[1]!=0) srcp+=2; - else break; - } - } - *dstp=0; + // Strip out any color escape sequences before writing to debug output + char * copy = new char[strlen(cp)+1]; + const char * srcp = cp; + char * dstp = copy; - OutputDebugStringA(copy); - delete [] copy; -#endif // _DEBUG + while (*srcp != 0) + { + if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) + { + *dstp++=*srcp++; + } + else + { + if (srcp[1]!=0) srcp+=2; + else break; + } + } + *dstp=0; + + OutputDebugStringA(copy); + delete [] copy; + } if (ConWindowHidden) {