changeset 63:146252a250d1

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Aug 2015 21:25:10 +0200
parents 130511d63f68
children da70170d367e
files Orthanc/Core/Enumerations.cpp Orthanc/Core/Enumerations.h Orthanc/Core/Logging.h Orthanc/Core/Toolbox.cpp Orthanc/Resources/CMake/JsonCppConfiguration.cmake
diffstat 5 files changed, 81 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Orthanc/Core/Enumerations.cpp	Fri Aug 07 21:24:47 2015 +0200
+++ b/Orthanc/Core/Enumerations.cpp	Fri Aug 07 21:25:10 2015 +0200
@@ -36,6 +36,8 @@
 #include "OrthancException.h"
 #include "Toolbox.h"
 
+#include <string.h>
+
 namespace Orthanc
 {
   const char* EnumerationToString(HttpMethod method)
@@ -368,6 +370,28 @@
   }
 
 
+  const char* EnumerationToString(LogLevel level)
+  {
+    switch (level)
+    {
+      case LogLevel_Error:
+        return "ERROR";
+
+      case LogLevel_Warning:
+        return "WARNING";
+
+      case LogLevel_Info:
+        return "INFO";
+
+      case LogLevel_Trace:
+        return "TRACE";
+
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
   Encoding StringToEncoding(const char* encoding)
   {
     std::string s(encoding);
@@ -493,6 +517,31 @@
   }
 
 
+  LogLevel StringToLogLevel(const char *level)
+  {
+    if (strcmp(level, "ERROR") == 0)
+    {
+      return LogLevel_Error;
+    }
+    else if (strcmp(level, "WARNING") == 0)
+    {
+      return LogLevel_Warning;
+    }
+    else if (strcmp(level, "INFO") == 0)
+    {
+      return LogLevel_Info;
+    }
+    else if (strcmp(level, "TRACE") == 0)
+    {
+      return LogLevel_Trace;
+    }
+    else 
+    {
+      throw OrthancException(ErrorCode_InternalError);
+    }
+  }
+
+
   unsigned int GetBytesPerPixel(PixelFormat format)
   {
     switch (format)
--- a/Orthanc/Core/Enumerations.h	Fri Aug 07 21:24:47 2015 +0200
+++ b/Orthanc/Core/Enumerations.h	Fri Aug 07 21:25:10 2015 +0200
@@ -76,6 +76,14 @@
     ErrorCode_Plugin
   };
 
+  enum LogLevel
+  {
+    LogLevel_Error,
+    LogLevel_Warning,
+    LogLevel_Info,
+    LogLevel_Trace
+  };
+
 
   /**
    * {summary}{The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.}
@@ -330,12 +338,16 @@
 
   const char* EnumerationToString(PhotometricInterpretation photometric);
 
+  const char* EnumerationToString(LogLevel level);
+
   Encoding StringToEncoding(const char* encoding);
 
   ResourceType StringToResourceType(const char* type);
 
   ImageFormat StringToImageFormat(const char* format);
 
+  LogLevel StringToLogLevel(const char* format);
+
   unsigned int GetBytesPerPixel(PixelFormat format);
 
   bool GetDicomEncoding(Encoding& encoding,
--- a/Orthanc/Core/Logging.h	Fri Aug 07 21:24:47 2015 +0200
+++ b/Orthanc/Core/Logging.h	Fri Aug 07 21:25:10 2015 +0200
@@ -35,12 +35,12 @@
 #if ORTHANC_ENABLE_LOGGING == 1
 
 #if ORTHANC_ENABLE_GOOGLE_LOG == 1
-#  include <stdlib.h>  // This fixes a problem in glog for recent releases of MinGW
+#  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 LOG(level)  ::Orthanc::Logging::InternalLogger(#level,  __FILE__, __LINE__)
 #  define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__)
 #endif
 
@@ -59,28 +59,30 @@
 
     void SetTargetFolder(const std::string& path);
 
+#if ORTHANC_ENABLE_GOOGLE_LOG != 1
+    struct NullStream : public std::ostream 
+    {
+      NullStream() : 
+        std::ios(0), 
+        std::ostream(0)
+      {
+      }
+    };
 
-#if ORTHANC_ENABLE_GOOGLE_LOG != 1
     class InternalLogger
     {
     private:
-      boost::mutex::scoped_lock  lock_;
-      std::ostream*              stream_;
+      boost::mutex::scoped_lock lock_;
+      NullStream                null_;
+      std::ostream*             stream_;
 
     public:
       InternalLogger(const char* level,
                      const char* file,
                      int line);
 
-      ~InternalLogger()
-      {
-#if defined(_WIN32)
-        *stream_ << "\r\n";
-#else
-        *stream_ << "\n";
-#endif
-      }
-
+      ~InternalLogger();
+      
       std::ostream& operator<< (const std::string& message)
       {
         return (*stream_) << message;
--- a/Orthanc/Core/Toolbox.cpp	Fri Aug 07 21:24:47 2015 +0200
+++ b/Orthanc/Core/Toolbox.cpp	Fri Aug 07 21:25:10 2015 +0200
@@ -437,7 +437,7 @@
     {
       return static_cast<uint64_t>(boost::filesystem::file_size(path));
     }
-    catch (boost::filesystem::filesystem_error)
+    catch (boost::filesystem::filesystem_error&)
     {
       throw OrthancException(ErrorCode_InexistentFile);
     }
--- a/Orthanc/Resources/CMake/JsonCppConfiguration.cmake	Fri Aug 07 21:24:47 2015 +0200
+++ b/Orthanc/Resources/CMake/JsonCppConfiguration.cmake	Fri Aug 07 21:25:10 2015 +0200
@@ -1,8 +1,8 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
-  set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.6.0-rc2)
+  set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.5)
   DownloadPackage(
-    "363e2f4cbd3aeb63bf4e571f377400fb"
-    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.6.0-rc2.tar.gz"
+    "db146bac5a126ded9bd728ab7b61ed6b"
+    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-0.10.5.tar.gz"
     "${JSONCPP_SOURCES_DIR}")
 
   set(JSONCPP_SOURCES