diff Core/Logging.h @ 1551:0dba274074eb

standalone logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Aug 2015 14:57:41 +0200
parents 46b2794042d6
children b1291df2f780
line wrap: on
line diff
--- a/Core/Logging.h	Mon Aug 17 15:57:44 2015 +0200
+++ b/Core/Logging.h	Tue Aug 18 14:57:41 2015 +0200
@@ -32,18 +32,7 @@
 
 #pragma once
 
-#if ORTHANC_ENABLE_LOGGING == 1
-
-#if ORTHANC_ENABLE_GOOGLE_LOG == 1
-#  include <stdlib.h>  // Including this fixes a problem in glog for recent releases of MinGW
-#  include <glog/logging.h>
-#else
-#  include <iostream>
-#  include <boost/thread/mutex.hpp>
-#  define LOG(level)  ::Orthanc::Logging::InternalLogger(#level,  __FILE__, __LINE__)
-#  define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__)
-#endif
-
+#include <iostream>
 
 namespace Orthanc
 {
@@ -59,7 +48,6 @@
 
     void SetTargetFolder(const std::string& path);
 
-#if ORTHANC_ENABLE_GOOGLE_LOG != 1
     struct NullStream : public std::ostream 
     {
       NullStream() : 
@@ -67,8 +55,37 @@
         std::ostream(0)
       {
       }
+      
+      std::ostream& operator<< (const std::string& message)
+      {
+        return *this;
+      }
     };
+  }
+}
 
+
+#if ORTHANC_ENABLE_LOGGING != 1
+
+#  define LOG(level)   ::Orthanc::Logging::NullStream()
+#  define VLOG(level)  ::Orthanc::Logging::NullStream()
+
+#else  /* ORTHANC_ENABLE_LOGGING == 1 */
+
+#if ORTHANC_ENABLE_GOOGLE_LOG == 1
+#  include <stdlib.h>  // Including this fixes a problem in glog for recent releases of MinGW
+#  include <glog/logging.h>
+#else
+#  include <boost/thread/mutex.hpp>
+#  define LOG(level)  ::Orthanc::Logging::InternalLogger(#level,  __FILE__, __LINE__)
+#  define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__)
+#endif
+
+#if ORTHANC_ENABLE_GOOGLE_LOG != 1
+namespace Orthanc
+{
+  namespace Logging
+  {
     class InternalLogger
     {
     private:
@@ -88,8 +105,8 @@
         return (*stream_) << message;
       }
     };
-#endif
   }
 }
+#endif
 
 #endif  // ORTHANC_ENABLE_LOGGING