]> git.mxchange.org Git - simgear.git/blobdiff - simgear/debug/logstream.hxx
Harald JOHNSEN:
[simgear.git] / simgear / debug / logstream.hxx
index 12c2dfeef9fb95e1a13b5f212c830d6aabeef991..4546a5e1d5cd6efbaa774eb475101a05584853af 100644 (file)
 
 #include <simgear/compiler.h>
 
+#ifdef _MSC_VER
+#  include <windows.h>
+#endif
+
 #ifdef SG_HAVE_STD_INCLUDES
 # include <streambuf>
 # include <iostream>
@@ -180,7 +184,23 @@ logbuf::set_log_state( sgDebugClass c, sgDebugPriority p )
 inline logbuf::int_type
 logbuf::overflow( int c )
 {
+#ifdef _MSC_VER
+    static has_console = false;
+    if ( logging_enabled ) {
+        if ( !has_console ) {
+            AllocConsole();
+            freopen("conin$", "r", stdin);
+            freopen("conout$", "w", stdout);
+            freopen("conout$", "w", stderr);
+            has_console = true;
+        }
+        sbuf->sputc(c);
+    }
+    else
+        return EOF == 0 ? 1: 0;
+#else
     return logging_enabled ? sbuf->sputc(c) : (EOF == 0 ? 1: 0);
+#endif
 }
 
 /**