From f1aac9e31727fc1a5a5bd23af026073905fda1e8 Mon Sep 17 00:00:00 2001 From: auria Date: Fri, 27 Dec 2013 03:02:33 +0000 Subject: [PATCH] Adjust logging to make STK less annoying to debug under visual studio : output the logging directly to VS's output pane, instead of having to reply on the small cmd.exe popup that closes as soon as the application exits git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14807 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/utils/log.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/utils/log.cpp b/src/utils/log.cpp index 98e58a8e3..61017d284 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -163,6 +163,10 @@ void Log::printMessage(int level, const char *component, const char *format, { va_copy(copy, args); } +#if defined(_MSC_FULL_VER) && defined(_DEBUG) + VALIST copy2; + va_copy(copy2, args); +#endif // If we don't have a console file, write to stdout and hope for the best if(!m_file_stdout || level >= LL_WARN || @@ -178,6 +182,21 @@ void Log::printMessage(int level, const char *component, const char *format, va_end(out); } + +#if defined(_MSC_FULL_VER) && defined(_DEBUG) + static char szBuff[2048]; + vsnprintf(szBuff, sizeof(szBuff), format, copy2); + + OutputDebugString("["); + OutputDebugString(names[level]); + OutputDebugString("] "); + OutputDebugString(component); + OutputDebugString(": "); + OutputDebugString(szBuff); + OutputDebugString("\r\n"); +#endif + + if(m_file_stdout) { fprintf (m_file_stdout, "[%s] %s: ", names[level], component);