From: Jasin Colegrove Date: Thu, 9 Jun 2016 18:27:56 +0000 (-0400) Subject: Use STD_ERROR_HANDLE since SG_LOG uses stderr stream X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f14eb32b1dcb7fd5bcff338a481e765b0bf04bf8;p=simgear.git Use STD_ERROR_HANDLE since SG_LOG uses stderr stream Fixed spacing, cleaned up uneccessary #ifdef's --- 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()); }