From f14eb32b1dcb7fd5bcff338a481e765b0bf04bf8 Mon Sep 17 00:00:00 2001 From: Jasin Colegrove Date: Thu, 9 Jun 2016 14:27:56 -0400 Subject: [PATCH] Use STD_ERROR_HANDLE since SG_LOG uses stderr stream Fixed spacing, cleaned up uneccessary #ifdef's --- simgear/debug/logstream.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index f481a656..dab15fce 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -227,20 +227,19 @@ public: #if defined (SG_WINDOWS) // Check for stream redirection, has to be done before we call // Attach / AllocConsole - const bool isFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_DISK); // Redirect to file? + const bool isFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_DISK); // Redirect to file? if (AttachConsole(ATTACH_PARENT_PROCESS) == 0) { // attach failed, don't install the callback addStderr = false; } + + if (!isFile) { + // No - OK! now set streams to attached console + freopen("conout$", "w", stdout); + freopen("conout$", "w", stderr); + } #endif if (addStderr) { -#if defined (SG_WINDOWS) - if (!isFile) { - // No - OK! now set streams to attached console - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); - } -#endif m_callbacks.push_back(new StderrLogCallback(m_logClass, m_logPriority)); m_consoleCallbacks.push_back(m_callbacks.back()); } -- 2.39.5