]> git.mxchange.org Git - simgear.git/blobdiff - simgear/debug/logstream.hxx
Use default OpenGL material colors
[simgear.git] / simgear / debug / logstream.hxx
index 5b57d50f0f8f977cb162cd90ed2a72a364291b1f..12c2dfeef9fb95e1a13b5f212c830d6aabeef991 100644 (file)
 
 #include <simgear/compiler.h>
 
-// At least Irix needs this
-#ifdef SG_HAVE_NATIVE_SGI_COMPILERS
-#include <char_traits.h>
-#endif
-
 #ifdef SG_HAVE_STD_INCLUDES
 # include <streambuf>
 # include <iostream>
 
 #include <simgear/debug/debug_types.h>
 
-#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
 SG_USING_STD(streambuf);
 SG_USING_STD(ostream);
+SG_USING_STD(cout);
 SG_USING_STD(cerr);
 SG_USING_STD(endl);
-#else
-SG_USING_STD(char_traits);
-#endif
 
 #ifdef __MWERKS__
 SG_USING_STD(iostream);
@@ -69,7 +61,11 @@ SG_USING_STD(iostream);
  * messages at runtime. Only messages with priority >= logbuf::logPriority
  * and debugClass == logbuf::logClass are output.
  */
+#ifdef SG_NEED_STREAMBUF_HACK
+class logbuf : public __streambuf
+#else
 class logbuf : public streambuf
+#endif
 {
 public:
 
@@ -256,6 +252,7 @@ logstream::operator<< ( const loglevel& l )
     return *this;
 }
 
+extern logstream *global_logstream;
 
 /**
  * \relates logstream
@@ -267,8 +264,22 @@ logstream::operator<< ( const loglevel& l )
 inline logstream&
 sglog()
 {
-    static logstream logstrm( cerr );
-    return logstrm;
+  if (global_logstream == NULL) {
+
+#ifdef __APPLE__
+    /**
+     * There appears to be a bug in the C++ runtime in Mac OS X that
+     * will crash if certain funtions are called (in this case
+     * cerr.rdbuf()) during static initialization of a class. This
+     * print statement is hack to kick the library in the pants so it
+     * won't crash when cerr.rdbuf() is first called -DW 
+     **/
+    cout << "Using Mac OS X hack for initializing C++ stdio..." << endl;
+#endif    
+    global_logstream = new logstream (cerr);
+  }
+    
+  return *global_logstream;
 }