changeset 4280:58e757ded69e

SetDcmtkVerbosity()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Nov 2020 07:56:22 +0100
parents ab4d015af660
children d2f79a475b51
files OrthancServer/Sources/OrthancInitialization.cpp OrthancServer/Sources/main.cpp
diffstat 2 files changed, 42 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancInitialization.cpp	Tue Nov 03 20:48:01 2020 +0100
+++ b/OrthancServer/Sources/OrthancInitialization.cpp	Wed Nov 04 07:56:22 2020 +0100
@@ -51,7 +51,8 @@
 
 #include <OrthancServerResources.h>
 
-#include <dcmtk/dcmnet/dul.h>   // For dcmDisableGethostbyaddr()
+#include <dcmtk/dcmnet/dul.h>     // For dcmDisableGethostbyaddr()
+#include <dcmtk/dcmnet/diutil.h>  // For DCM_dcmnetLogger
 
 
 
@@ -393,11 +394,44 @@
   IStorageArea* CreateStorageArea()
   {
     return CreateFilesystemStorage();
-  }  
+  }
+
+
+  static void SetDcmtkVerbosity(Verbosity verbosity)
+  {
+    // https://support.dcmtk.org/docs-dcmrt/classOFLogger.html#ae20bf2616f15313c1f089da2eefb8245
+    OFLogger::LogLevel level;
+
+    switch (verbosity)
+    {
+      case Verbosity_Default:
+        level = OFLogger::OFF_LOG_LEVEL;  // No log
+        break;
+
+      case Verbosity_Verbose:
+        level = OFLogger::INFO_LOG_LEVEL;  // This was the default log level in Orthanc <= 1.8.0
+        break;
+
+      case Verbosity_Trace:
+        level = OFLogger::DEBUG_LOG_LEVEL;
+        break;
+
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+
+    OFLog::configure(level);
+    assert(dcmtk::log4cplus::Logger::getRoot().getChainedLogLevel() == level);
+    
+    DCM_dcmdataLogger.setLogLevel(level);
+    DCM_dcmnetLogger.setLogLevel(level);
+  }
 
 
   void SetGlobalVerbosity(Verbosity verbosity)
   {
+    SetDcmtkVerbosity(verbosity);
+    
     switch (verbosity)
     {
       case Verbosity_Default:
@@ -461,6 +495,11 @@
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
+
+    if (category == Logging::LogCategory_DICOM)
+    {
+      SetDcmtkVerbosity(verbosity);
+    }
   }
   
 
--- a/OrthancServer/Sources/main.cpp	Tue Nov 03 20:48:01 2020 +0100
+++ b/OrthancServer/Sources/main.cpp	Wed Nov 04 07:56:22 2020 +0100
@@ -1535,6 +1535,7 @@
 int main(int argc, char* argv[]) 
 {
   Logging::Initialize();
+  SetGlobalVerbosity(Verbosity_Default);
 
   bool upgradeDatabase = false;
   bool loadJobsFromDatabase = true;