changeset 5573:823aae1ea72a

removed dependency of HouseKeeper upon Orthanc::Logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 Apr 2024 16:01:26 +0200
parents f0dc99bc811c
children d7eaa568da15
files NEWS OrthancServer/CMakeLists.txt OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp
diffstat 3 files changed, 36 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Apr 26 15:50:01 2024 +0200
+++ b/NEWS	Fri Apr 26 16:01:26 2024 +0200
@@ -34,10 +34,12 @@
 * Housekeeper plugin: Added an option "LimitMainDicomTagsReconstructLevel"
   (allowed values: "Patient", "Study", "Series", "Instance").  This can greatly speed
   up the housekeeper process e.g. if you have only update the Study level ExtraMainDicomTags.
-* SDK: added OrthancPluginLogMessage that is a new primitive for plugins to log messages.
-  This new primitive will display the plugin name, plugin file name and plugin line number
-  in the logs.  If they are using the OrthancFramework, plugins should now use LOG(INFO),
-  LOG(WARNING) and LOG(ERROR) to log their messages.
+* SDK: added OrthancPluginLogMessage() that is a new primitive for
+  plugins to log messages.  This new primitive will display the plugin
+  name, the plugin file name, and the plugin line number in the
+  logs. If they are not using the LOG() facilities provided by the
+  OrthancFramework, plugins should now use ORTHANC_PLUGINS_LOG_INFO(),
+  ORTHANC_PLUGINS_LOG_WARNING(), and ORTHANC_PLUGINS_LOG_ERROR().
 
 
 Version 1.12.3 (2024-01-31)
--- a/OrthancServer/CMakeLists.txt	Fri Apr 26 15:50:01 2024 +0200
+++ b/OrthancServer/CMakeLists.txt	Fri Apr 26 16:01:26 2024 +0200
@@ -496,10 +496,6 @@
     
     ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/ThirdParty/base64/base64.cpp
     ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/ThirdParty/md5/md5.c
-
-    # the orthanc framework sources
-    ${ORTHANC_CORE_SOURCES}
-
     Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
     )
 
@@ -524,8 +520,6 @@
 
   DefineSourceBasenameForTarget(PluginsDependencies)
 
-  target_include_directories(PluginsDependencies PUBLIC ${CMAKE_SOURCE_DIR}/../OrthancFramework/Sources)
-
   # Add the "-fPIC" option as this static library must be embedded
   # inside shared libraries (important on UNIX)
   set_target_properties(
--- a/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Fri Apr 26 15:50:01 2024 +0200
+++ b/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Fri Apr 26 16:01:26 2024 +0200
@@ -22,8 +22,6 @@
 
 #define HOUSEKEEPER_NAME "housekeeper"
 
-#include "../../../../OrthancFramework/Sources/Compatibility.h"
-#include "../../../../OrthancFramework/Sources/Logging.h"
 #include "../Common/OrthancPluginCppWrapper.h"
 
 #include <boost/thread.hpp>
@@ -92,7 +90,7 @@
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: invalid schedule: unknown 'day': " << weekday;
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: invalid schedule: unknown 'day': " + weekday);
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
 
@@ -404,12 +402,12 @@
   {
     if (triggerOnUnnecessaryDicomAsJsonFiles_)
     {
-      LOG(WARNING) << "Housekeeper: your storage might still contain some dicom-as-json files -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: your storage might still contain some dicom-as-json files -> will perform housekeeping");
       needsReconstruct = true;  // the default reconstruct removes the dicom-as-json
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: your storage might still contain some dicom-as-json files but the trigger has been disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: your storage might still contain some dicom-as-json files but the trigger has been disabled");
     }
   }
 
@@ -417,12 +415,12 @@
   {
     if (triggerOnMainDicomTagsChange_)
     {
-      LOG(WARNING) << "Housekeeper: Patient main dicom tags have changed, -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Patient main dicom tags have changed, -> will perform housekeeping");
       needsReconstruct = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: Patient main dicom tags have changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Patient main dicom tags have changed but the trigger is disabled");
     }
   }
 
@@ -430,12 +428,12 @@
   {
     if (triggerOnMainDicomTagsChange_)
     {
-      LOG(WARNING) << "Housekeeper: Study main dicom tags have changed, -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Study main dicom tags have changed, -> will perform housekeeping");
       needsReconstruct = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: Study main dicom tags have changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Study main dicom tags have changed but the trigger is disabled");
     }
   }
 
@@ -443,12 +441,12 @@
   {
     if (triggerOnMainDicomTagsChange_)
     {
-      LOG(WARNING) << "Housekeeper: Series main dicom tags have changed, -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Series main dicom tags have changed, -> will perform housekeeping");
       needsReconstruct = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: Series main dicom tags have changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Series main dicom tags have changed but the trigger is disabled");
     }
   }
 
@@ -456,12 +454,12 @@
   {
     if (triggerOnMainDicomTagsChange_)
     {
-      LOG(WARNING) << "Housekeeper: Instance main dicom tags have changed, -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Instance main dicom tags have changed, -> will perform housekeeping");
       needsReconstruct = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: Instance main dicom tags have changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: Instance main dicom tags have changed but the trigger is disabled");
     }
   }
 
@@ -471,18 +469,18 @@
     {
       if (current.storageCompressionEnabled)
       {
-        LOG(WARNING) << "Housekeeper: storage compression is now enabled -> will perform housekeeping";
+        ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: storage compression is now enabled -> will perform housekeeping");
       }
       else
       {
-        LOG(WARNING) << "Housekeeper: storage compression is now disabled -> will perform housekeeping";
+        ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: storage compression is now disabled -> will perform housekeeping");
       }
       
       needsReingest = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: storage compression has changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: storage compression has changed but the trigger is disabled");
     }
   }
 
@@ -490,13 +488,13 @@
   {
     if (triggerOnIngestTranscodingChange_)
     {
-      LOG(WARNING) << "Housekeeper: ingest transcoding has changed -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: ingest transcoding has changed -> will perform housekeeping");
       
       needsReingest = true;
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: ingest transcoding has changed but the trigger is disabled";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: ingest transcoding has changed but the trigger is disabled");
     }
   }
 
@@ -506,7 +504,7 @@
     {
       if (triggerOnDicomWebCacheChange_)
       {
-        LOG(WARNING) << "Housekeeper: DicomWEB plugin is enabled and the housekeeper has never run, you might miss series metadata cache -> will perform housekeeping";
+        ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: DicomWEB plugin is enabled and the housekeeper has never run, you might miss series metadata cache -> will perform housekeeping");
       }
       needsDicomWebCaching = triggerOnDicomWebCacheChange_;
     }
@@ -518,12 +516,12 @@
       {
         if (triggerOnDicomWebCacheChange_)
         {
-          LOG(WARNING) << "Housekeeper: DicomWEB plugin might miss series metadata cache -> will perform housekeeping";
+          ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: DicomWEB plugin might miss series metadata cache -> will perform housekeeping");
           needsDicomWebCaching = true;
         }
         else
         {
-          LOG(WARNING) << "Housekeeper: DicomWEB plugin might miss series metadata cache but the trigger has been disabled";
+          ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: DicomWEB plugin might miss series metadata cache but the trigger has been disabled");
         }
       }
     }
@@ -660,7 +658,7 @@
 
   if (!needsProcessing)
   {
-    LOG(WARNING) << "Housekeeper: everything has been processed already !";
+    ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: everything has been processed already !");
     return;
   }
 
@@ -668,11 +666,11 @@
   {
     if (force_)
     {
-      LOG(WARNING) << "Housekeeper: forcing execution -> will perform housekeeping";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: forcing execution -> will perform housekeeping");
     }
     else
     {
-      LOG(WARNING) << "Housekeeper: the DB configuration has changed since last run, will reprocess the whole DB !";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: the DB configuration has changed since last run, will reprocess the whole DB !");
     }
     
     Json::Value changes;
@@ -688,7 +686,7 @@
   }
   else
   {
-    LOG(WARNING) << "Housekeeper: the DB configuration has not changed since last run, will continue processing changes";
+    ORTHANC_PLUGINS_LOG_WARNING("Housekeeper: the DB configuration has not changed since last run, will continue processing changes");
   }
 
   bool completed = false;
@@ -710,7 +708,8 @@
       {
         boost::recursive_mutex::scoped_lock lock(pluginStatusMutex_);
     
-        LOG(INFO) << "Housekeeper: processed changes " << pluginStatus_.lastProcessedChange << " / " << pluginStatus_.lastChangeToProcess;
+        ORTHANC_PLUGINS_LOG_INFO("Housekeeper: processed changes " + boost::lexical_cast<std::string>(pluginStatus_.lastProcessedChange) +
+                                 " / " + boost::lexical_cast<std::string>(pluginStatus_.lastChangeToProcess));
         
         boost::this_thread::sleep(boost::posix_time::milliseconds(throttleDelay_ * 100));  // wait 1/10 of the delay between changes
       }
@@ -721,7 +720,7 @@
     {
       if (!loggedNotRightPeriodChangeMessage)
       {
-        LOG(INFO) << "Housekeeper: entering quiet period";
+        ORTHANC_PLUGINS_LOG_INFO("Housekeeper: entering quiet period");
         loggedNotRightPeriodChangeMessage = true;
       }
 
@@ -796,7 +795,6 @@
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
   {
     OrthancPlugins::SetGlobalContext(c, HOUSEKEEPER_NAME);
-    Orthanc::Logging::InitializePluginContext(c, HOUSEKEEPER_NAME);
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(c) == 0)
@@ -807,7 +805,7 @@
       return -1;
     }
 
-    LOG(WARNING) << "Housekeeper plugin is initializing";
+    ORTHANC_PLUGINS_LOG_WARNING("Housekeeper plugin is initializing");
     OrthancPluginSetDescription2(c, HOUSEKEEPER_NAME, "Optimizes your DB and storage.");
 
     OrthancPlugins::OrthancConfiguration orthancConfiguration;
@@ -891,7 +889,7 @@
       if (limitMainDicomTagsReconstructLevel_ != "Patient" && limitMainDicomTagsReconstructLevel_ != "Study"
         && limitMainDicomTagsReconstructLevel_ != "Series" && limitMainDicomTagsReconstructLevel_ != "Instance")
       {
-        LOG(ERROR) << "Housekeeper invalid value for 'LimitMainDicomTagsReconstructLevel': '" << limitMainDicomTagsReconstructLevel_ << "'";
+        ORTHANC_PLUGINS_LOG_ERROR("Housekeeper invalid value for 'LimitMainDicomTagsReconstructLevel': '" + limitMainDicomTagsReconstructLevel_ + "'");
       }
       else if (limitMainDicomTagsReconstructLevel_ == "Patient")
       {
@@ -925,7 +923,7 @@
     }
     else
     {
-      LOG(WARNING) << "Housekeeper plugin is disabled by the configuration file";
+      ORTHANC_PLUGINS_LOG_WARNING("Housekeeper plugin is disabled by the configuration file");
     }
 
     return 0;
@@ -934,7 +932,7 @@
 
   ORTHANC_PLUGINS_API void OrthancPluginFinalize()
   {
-    LOG(WARNING) << "Housekeeper plugin is finalizing";
+    ORTHANC_PLUGINS_LOG_WARNING("Housekeeper plugin is finalizing");
   }