changeset 2484:911e62dbb4ac

logging to stdio
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Mar 2018 18:25:07 +0100
parents 9c54c40eaf25
children a5196a7d98c6
files Core/Logging.cpp Core/Logging.h
diffstat 2 files changed, 7 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Logging.cpp	Fri Mar 02 15:10:37 2018 +0100
+++ b/Core/Logging.cpp	Fri Mar 02 18:25:07 2018 +0100
@@ -133,24 +133,6 @@
         }
       }
     }
-
-    InternalLogger& InternalLogger::operator<< (const std::string& message)
-    {
-      message_ += message;
-      return *this;
-    }
-
-    InternalLogger& InternalLogger::operator<< (const char* message)
-    {
-      message_ += std::string(message);
-      return *this;
-    }
-
-    InternalLogger& InternalLogger::operator<< (int message)
-    {
-      message_ += boost::lexical_cast<std::string>(message);
-      return *this;
-    }
   }
 }
 
@@ -209,24 +191,6 @@
       }
     }
 
-    InternalLogger& InternalLogger::operator<< (const std::string& message)
-    {
-      message_ += message;
-      return *this;
-    }
-
-    InternalLogger& InternalLogger::operator<< (const char* message)
-    {
-      message_ += std::string(message);
-      return *this;
-    }
-
-    InternalLogger& InternalLogger::operator<< (int message)
-    {
-      message_ += boost::lexical_cast<std::string>(message);
-      return *this;
-    }
-
     void EnableInfoLevel(bool enabled)
     {
       globalVerbose_ = enabled;
--- a/Core/Logging.h	Fri Mar 02 15:10:37 2018 +0100
+++ b/Core/Logging.h	Fri Mar 02 18:25:07 2018 +0100
@@ -116,6 +116,7 @@
        ORTHANC_ENABLE_LOGGING_STDIO == 1)
 
 #  include <boost/noncopyable.hpp>
+#  include <boost/lexical_cast.hpp>
 #  define LOG(level)  ::Orthanc::Logging::InternalLogger \
   (::Orthanc::Logging::level, __FILE__, __LINE__)
 #  define VLOG(level) ::Orthanc::Logging::InternalLogger \
@@ -146,11 +147,12 @@
 
       ~InternalLogger();
       
-      InternalLogger& operator<< (const std::string& message);
-
-      InternalLogger& operator<< (const char* message);
-
-      InternalLogger& operator<< (int message);
+      template <typename T>
+      InternalLogger& operator<< (T message)
+      {
+        message_ += boost::lexical_cast<std::string>(message);
+        return *this;
+      }
     };
   }
 }