]> git.mxchange.org Git - simgear.git/commitdiff
Use STD_ERROR_HANDLE since SG_LOG uses stderr stream
authorJasin Colegrove <jasin@coleburt.com>
Thu, 9 Jun 2016 18:27:56 +0000 (14:27 -0400)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
Fixed spacing, cleaned up uneccessary #ifdef's

simgear/debug/logstream.cxx

index f481a65626790384392f1c92a8c43d9714d29bae..dab15fce94542a3fe1f4ebf097006bc58b3654ed 100644 (file)
@@ -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());
         }