changeset 650:4fe4279625f8

The plugin now uses the new logging primitives from Orthanc 1.12.4
author Alain Mazy <am@orthanc.team>
date Tue, 23 Apr 2024 09:46:17 +0200
parents 1efd6296c589
children a81094c314a8
files NEWS Plugin/Configuration.cpp Plugin/DicomWebClient.cpp Plugin/DicomWebServers.cpp Plugin/Plugin.cpp Plugin/QidoRs.cpp Plugin/StowRs.cpp Plugin/WadoRsRetrieveFrames.cpp Plugin/WadoUri.cpp Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h TODO
diffstat 12 files changed, 237 insertions(+), 132 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jan 24 13:28:34 2024 +0100
+++ b/NEWS	Tue Apr 23 09:46:17 2024 +0200
@@ -6,6 +6,7 @@
 
 * WADO-RS retrieve frame: fix issue 219 (https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=219)
   by converting BigEndianExplicitVR to LittleEndianExplicitVR.
+* The plugin now uses the new logging primitives from Orthanc 1.12.4
 
 
 Version 1.16 (2023-12-19)
--- a/Plugin/Configuration.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/Configuration.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -635,8 +635,8 @@
       }
       else
       {
-        LogError("Unsupported return MIME type: " + accept +
-                 ", will return DICOM+JSON");
+        LOG(ERROR) << "Unsupported return MIME type: " << accept <<
+                      ", will return DICOM+JSON";
         return false;
       }
     }
--- a/Plugin/DicomWebClient.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/DicomWebClient.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -919,8 +919,8 @@
   Json::Value resourcesForJobContent;
   ParseStowRequest(instances, httpHeaders, resourcesForJobContent, body);
 
-  OrthancPlugins::LogInfo("Sending " + boost::lexical_cast<std::string>(instances.size()) +
-                          " instances using STOW-RS to DICOMweb server: " + serverName);
+  LOG(INFO) << "Sending " << boost::lexical_cast<std::string>(instances.size()) <<
+               " instances using STOW-RS to DICOMweb server: " << serverName;
 
   std::unique_ptr<StowClientJob> job(new StowClientJob(serverName, instances, httpHeaders, resourcesForJobContent));
 
--- a/Plugin/DicomWebServers.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/DicomWebServers.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -26,6 +26,7 @@
 
 #include <Compatibility.h>
 #include <Toolbox.h>
+#include <Logging.h>
 
 #include <boost/algorithm/string/predicate.hpp>
 
@@ -72,8 +73,8 @@
     }
     catch (Orthanc::OrthancException& e)
     {
-      LogError("Exception while parsing the \"DicomWeb.Servers\" section "
-               "of the configuration file: " + std::string(e.What()));
+      LOG(ERROR) << "Exception while parsing the \"DicomWeb.Servers\" section "
+                    "of the configuration file: " + std::string(e.What());
       throw;
     }
 
--- a/Plugin/Plugin.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/Plugin.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -40,7 +40,7 @@
 #define ORTHANC_CORE_MINIMAL_MINOR     11
 #define ORTHANC_CORE_MINIMAL_REVISION  0
 
-
+#define PLUGIN_NAME "dicom-web"
 static const char* const HAS_DELETE = "HasDelete";
 
 
@@ -499,12 +499,21 @@
   {
     assert(DisplayPerformanceWarning(context));
 
+#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4) && ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+
+    OrthancPlugins::SetGlobalContext(context, PLUGIN_NAME);
+    Orthanc::Logging::InitializePluginContext(context, PLUGIN_NAME);
+
+#elif ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2)
+
     OrthancPlugins::SetGlobalContext(context);
-    
-#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2)
     Orthanc::Logging::InitializePluginContext(context);
+
 #else
+
+    OrthancPlugins::SetGlobalContext(context);
     Orthanc::Logging::Initialize(context);
+
 #endif
 
     Orthanc::Logging::EnableInfoLevel(true);
@@ -518,7 +527,7 @@
               ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
               ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
               ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
-      OrthancPluginLogError(context, info);
+      LOG(ERROR) << info;
       return -1;
     }
 
@@ -532,7 +541,7 @@
               ORTHANC_CORE_MINIMAL_MAJOR,
               ORTHANC_CORE_MINIMAL_MINOR,
               ORTHANC_CORE_MINIMAL_REVISION);
-      OrthancPluginLogError(context, info);
+      LOG(ERROR) << info;
       return -1;
     }
 
@@ -561,7 +570,7 @@
         std::string root = OrthancPlugins::Configuration::GetDicomWebRoot();
         assert(!root.empty() && root[root.size() - 1] == '/');
 
-        OrthancPlugins::LogWarning("URI to the DICOMweb REST API: " + root);
+        LOG(WARNING) << "URI to the DICOMweb REST API: " << root;
 
         OrthancPlugins::ChunkedRestRegistration<
           SearchForStudies /* TODO => Rename as QIDO-RS */,
@@ -643,35 +652,34 @@
         OrthancPluginSetRootUri(context, uri.c_str());
 
         std::string publicUrlRoot = OrthancPlugins::Configuration::GetPublicRoot();
-        OrthancPlugins::LogWarning("DICOMWeb PublicRoot: " + publicUrlRoot);
+        LOG(WARNING) << "DICOMWeb PublicRoot: " << publicUrlRoot;
       }
       else
       {
-        OrthancPlugins::LogWarning("DICOMweb support is disabled");
+        LOG(WARNING) << "DICOMweb support is disabled";
       }
 
       // Configure the WADO callback
       if (OrthancPlugins::Configuration::GetBooleanValue("EnableWado", true))
       {
         std::string wado = OrthancPlugins::Configuration::GetWadoRoot();
-        OrthancPlugins::LogWarning("URI to the WADO-URI API: " + wado);
+        LOG(WARNING) << "URI to the WADO-URI API: " << wado;
 
         OrthancPlugins::RegisterRestCallback<WadoUriCallback>(wado, true);
       }
       else
       {
-        OrthancPlugins::LogWarning("WADO-URI support is disabled");
+        LOG(WARNING) << "WADO-URI support is disabled";
       }
     }
     catch (Orthanc::OrthancException& e)
     {
-      OrthancPlugins::LogError("Exception while initializing the DICOMweb plugin: " + 
-                               std::string(e.What()));
+      LOG(ERROR) << "Exception while initializing the DICOMweb plugin: " << e.What();
       return -1;
     }
     catch (...)
     {
-      OrthancPlugins::LogError("Exception while initializing the DICOMweb plugin");
+      LOG(ERROR) << "Exception while initializing the DICOMweb plugin";
       return -1;
     }
 
@@ -686,7 +694,7 @@
 
   ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
   {
-    return "dicom-web";
+    return PLUGIN_NAME;
   }
 
 
--- a/Plugin/QidoRs.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/QidoRs.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -201,7 +201,7 @@
         }
       }
 
-      OrthancPlugins::LogInfo("Arguments of QIDO-RS request:" + args);
+      LOG(INFO) << "Arguments of QIDO-RS request:" << args;
     }
 
     unsigned int GetLimit() const
@@ -283,9 +283,8 @@
       if (offset_ != 0 &&
           !OrthancPlugins::CheckMinimalOrthancVersion(1, 3, 0))
       {
-        OrthancPlugins::LogError(
-          "QIDO-RS request with \"offset\" argument: "
-          "Only available if the Orthanc core version is >= 1.3.0");
+        LOG(ERROR) << "QIDO-RS request with \"offset\" argument: "
+                      "Only available if the Orthanc core version is >= 1.3.0";
       }
       
       for (Filters::const_iterator it = filters_.begin(); 
--- a/Plugin/StowRs.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/StowRs.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -24,7 +24,7 @@
 
 #include "Configuration.h"
 #include "DicomWebFormatter.h"
-
+#include "Logging.h"
 
 namespace OrthancPlugins
 {
@@ -116,7 +116,7 @@
     if (!ok)
     {
       // Bad DICOM file
-      LogWarning("STOW-RS cannot parse an incoming DICOM file");
+      LOG(WARNING) << "STOW-RS cannot parse an incoming DICOM file";
       hasBadSyntax_ = true;
       return;
     }
@@ -131,7 +131,7 @@
         dicom[Orthanc::DICOM_TAG_SOP_INSTANCE_UID.Format()].type() != Json::stringValue ||
         dicom[Orthanc::DICOM_TAG_STUDY_INSTANCE_UID.Format()].type() != Json::stringValue)
     {
-      LogWarning("STOW-RS: Missing a mandatory tag in incoming DICOM file");
+      LOG(WARNING) << "STOW-RS: Missing a mandatory tag in incoming DICOM file";
       hasBadSyntax_ = true;      
 
       if (dicom.isMember(Orthanc::DICOM_TAG_SOP_CLASS_UID.Format()) &&
@@ -162,8 +162,8 @@
     if (!expectedStudy_.empty() &&
         studyInstanceUid != expectedStudy_)
     {
-      LogWarning("STOW-RS request restricted to study [" + expectedStudy_ + 
-                 "], but received instance from study [" + studyInstanceUid + "]");
+      LOG(WARNING) << "STOW-RS request restricted to study [" << expectedStudy_ << 
+                      "], but received instance from study [" << studyInstanceUid << "]";
 
       hasConflict_ = true;
 
@@ -224,7 +224,7 @@
       }
       else
       {
-        LogError("Orthanc was unable to store one instance in a STOW-RS request");
+        LOG(ERROR) << "Orthanc was unable to store one instance in a STOW-RS request";
         item[DICOM_TAG_FAILURE_REASON.Format()] =
           boost::lexical_cast<std::string>(failureReason);
         failed_.append(item);
@@ -308,11 +308,11 @@
 
     if (expectedStudy.empty())
     {
-      LogInfo("STOW-RS request without study");
+      LOG(INFO) << "STOW-RS request without study";
     }
     else
     {
-      LogInfo("STOW-RS request restricted to study UID " + expectedStudy);
+      LOG(INFO) << "STOW-RS request restricted to study UID " << expectedStudy;
     }
 
     return new StowServer(context, headers, expectedStudy);
--- a/Plugin/WadoRsRetrieveFrames.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/WadoRsRetrieveFrames.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -25,6 +25,7 @@
 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 
 #include <Toolbox.h>
+#include <Logging.h>
 
 #include <memory>
 #include <list>
@@ -446,7 +447,7 @@
     { // logging only
       if (allFrames)
       {
-        OrthancPlugins::LogInfo("DICOMweb RetrieveFrames on " + orthancId + ", all frames");
+        LOG(INFO) << "DICOMweb RetrieveFrames on " << orthancId << ", all frames";
       }
       else
       {
@@ -457,7 +458,7 @@
           s += boost::lexical_cast<std::string>(*frame + 1) + " ";
         }
 
-        OrthancPlugins::LogInfo(s);
+        LOG(INFO) << s;
       }
     }
 
@@ -508,8 +509,8 @@
 
       if (transcodeThisInstance)
       {
-        OrthancPlugins::LogInfo("DICOMweb RetrieveFrames: Transcoding instance " + orthancId + 
-                                " to transfer syntax " + Orthanc::GetTransferSyntaxUid(targetSyntax));
+        LOG(INFO) << "DICOMweb RetrieveFrames: Transcoding instance " + orthancId
+                  << " to transfer syntax " << Orthanc::GetTransferSyntaxUid(targetSyntax);
 
         instance.reset(OrthancPlugins::DicomInstance::Transcode(
                        content.GetData(), content.GetSize(), GetTransferSyntaxUid(targetSyntax)));
--- a/Plugin/WadoUri.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Plugin/WadoUri.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -24,6 +24,7 @@
 
 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 #include "Configuration.h"
+#include "Logging.h"
 
 #include <string>
 
@@ -84,19 +85,19 @@
 
   if (requestType != "WADO")
   {
-    OrthancPlugins::LogError("WADO-URI: Invalid requestType: \"" + requestType + "\"");
+    LOG(ERROR) << "WADO-URI: Invalid requestType: \"" << requestType << "\"";
     return false;
   }
 
   if (objectUid.empty())
   {
-    OrthancPlugins::LogError("WADO-URI: No SOPInstanceUID provided");
+    LOG(ERROR) << "WADO-URI: No SOPInstanceUID provided";
     return false;
   }
 
   if (!MapWadoToOrthancIdentifier(instance, OrthancPluginLookupInstance, objectUid))
   {
-    OrthancPlugins::LogError("WADO-URI: No such SOPInstanceUID in Orthanc: \"" + objectUid + "\"");
+    LOG(ERROR) << "WADO-URI: No such SOPInstanceUID in Orthanc: \"" << objectUid << "\"";
     return false;
   }
 
@@ -110,7 +111,7 @@
     std::string series;
     if (!MapWadoToOrthancIdentifier(series, OrthancPluginLookupSeries, seriesUid))
     {
-      OrthancPlugins::LogError("WADO-URI: No such SeriesInstanceUID in Orthanc: \"" + seriesUid + "\"");
+      LOG(ERROR) << "WADO-URI: No such SeriesInstanceUID in Orthanc: \"" << seriesUid << "\"";
       return false;
     }
     else
@@ -119,7 +120,7 @@
       if (!OrthancPlugins::RestApiGet(info, "/instances/" + instance + "/series", false) ||
           info["MainDicomTags"]["SeriesInstanceUID"] != seriesUid)
       {
-        OrthancPlugins::LogError("WADO-URI: Instance " + objectUid + " does not belong to series " + seriesUid);
+        LOG(ERROR) << "WADO-URI: Instance " << objectUid << " does not belong to series " << seriesUid;
         return false;
       }
     }
@@ -130,7 +131,7 @@
     std::string study;
     if (!MapWadoToOrthancIdentifier(study, OrthancPluginLookupStudy, studyUid))
     {
-      OrthancPlugins::LogError("WADO-URI: No such StudyInstanceUID in Orthanc: \"" + studyUid + "\"");
+      LOG(ERROR) << "WADO-URI: No such StudyInstanceUID in Orthanc: \"" << studyUid << "\"";
       return false;
     }
     else
@@ -139,7 +140,7 @@
       if (!OrthancPlugins::RestApiGet(info, "/instances/" + instance + "/study", false) ||
           info["MainDicomTags"]["StudyInstanceUID"] != studyUid)
       {
-        OrthancPlugins::LogError("WADO-URI: Instance " + objectUid + " does not belong to study " + studyUid);
+        LOG(ERROR) << "WADO-URI: Instance " << objectUid << " does not belong to study " << studyUid;
         return false;
       }
     }
@@ -193,7 +194,7 @@
   }
   else
   {
-    OrthancPlugins::LogError("WADO-URI: Unable to generate a preview image for " + uri);
+    LOG(ERROR) << "WADO-URI: Unable to generate a preview image for " << uri;
     throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin);
   }
 }
--- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp	Wed Jan 24 13:28:34 2024 +0100
+++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp	Tue Apr 23 09:46:17 2024 +0200
@@ -2,8 +2,8 @@
  * Orthanc - A Lightweight, RESTful DICOM Store
  * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
  * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2023 Osimis S.A., Belgium
- * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ * Copyright (C) 2017-2024 Osimis S.A., Belgium
+ * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
  *
  * This program is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -79,9 +79,20 @@
     }
   }
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4)
+  static const char* pluginName_ = NULL;
+
+  void SetGlobalContext(OrthancPluginContext* context, const char* pluginName)
+  {
+    SetGlobalContext(context);
+    pluginName_ = pluginName;
+  }
+#endif
+
   void ResetGlobalContext()
   {
     globalContext_ = NULL;
+    pluginName_ = NULL;
   }
 
   bool HasGlobalContext()
@@ -102,6 +113,54 @@
     }
   }
 
+  void LogError(const std::string& message)
+  {
+    if (HasGlobalContext())
+    {
+      OrthancPluginLogError(GetGlobalContext(), message.c_str());
+    }
+  }
+
+  void LogWarning(const std::string& message)
+  {
+    if (HasGlobalContext())
+    {
+      OrthancPluginLogWarning(GetGlobalContext(), message.c_str());
+    }
+  }
+
+  void LogInfo(const std::string& message)
+  {
+    if (HasGlobalContext())
+    {
+      OrthancPluginLogInfo(GetGlobalContext(), message.c_str());
+    }
+  }
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4)
+  // This file does not have any dependencies on Logging.h, we must call the "native" plugin service
+
+  void _LogMessage(OrthancPluginLogLevel level, const char* file, uint32_t line, const std::string& message)
+  {
+    if (HasGlobalContext())
+    {
+      OrthancPluginLogMessage(GetGlobalContext(), message.c_str(), pluginName_, file, line, OrthancPluginLogCategory_Generic, level);
+    }
+  }
+
+  #define LOG_ERROR(msg) _LogMessage(OrthancPluginLogLevel_Error, __ORTHANC_FILE__, __LINE__, msg);
+  #define LOG_WARNING(msg) _LogMessage(OrthancPluginLogLevel_Warning, __ORTHANC_FILE__, __LINE__, msg);
+  #define LOG_INFO(msg) _LogMessage(OrthancPluginLogLevel_Info, __ORTHANC_FILE__, __LINE__, msg);
+
+#else
+
+  #define LOG_ERROR(msg) LogError(msg);
+  #define LOG_WARNING(msg) LogWarning(msg);
+  #define LOG_INFO(msg) LogInfo(msg);
+
+#endif
+
 
   void MemoryBuffer::Check(OrthancPluginErrorCode code)
   {
@@ -233,7 +292,7 @@
 
     if (!ReadJson(target, buffer_.data, buffer_.size))
     {
-      LogError("Cannot convert some memory buffer to JSON");
+      LOG_ERROR("Cannot convert some memory buffer to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
@@ -404,7 +463,7 @@
     }
     else
     {
-      LogError("Cannot parse JSON: " + std::string(err));
+      LOG_ERROR("Cannot parse JSON: " + std::string(err));
       return false;
     }
 #endif
@@ -565,13 +624,13 @@
   {
     if (str_ == NULL)
     {
-      LogError("Cannot convert an empty memory buffer to JSON");
+      LOG_ERROR("Cannot convert an empty memory buffer to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
     if (!ReadJson(target, str_))
     {
-      LogError("Cannot convert some memory buffer to JSON");
+      LOG_ERROR("Cannot convert some memory buffer to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
@@ -581,13 +640,13 @@
   {
     if (str_ == NULL)
     {
-      LogError("Cannot convert an empty memory buffer to JSON");
+      LOG_ERROR("Cannot convert an empty memory buffer to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
     if (!ReadJsonWithoutComments(target, str_))
     {
-      LogError("Cannot convert some memory buffer to JSON");
+      LOG_ERROR("Cannot convert some memory buffer to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
@@ -625,7 +684,7 @@
 
     if (body.size() > 0xffffffffu)
     {
-      LogError("Cannot handle body size > 4GB");
+      LOG_ERROR("Cannot handle body size > 4GB");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -645,7 +704,7 @@
 
     if (body.size() > 0xffffffffu)
     {
-      LogError("Cannot handle body size > 4GB");
+      LOG_ERROR("Cannot handle body size > 4GB");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -688,34 +747,6 @@
     }
   }
 
-
-  void LogError(const std::string& message)
-  {
-    if (HasGlobalContext())
-    {
-      OrthancPluginLogError(GetGlobalContext(), message.c_str());
-    }
-  }
-
-
-  void LogWarning(const std::string& message)
-  {
-    if (HasGlobalContext())
-    {
-      OrthancPluginLogWarning(GetGlobalContext(), message.c_str());
-    }
-  }
-
-
-  void LogInfo(const std::string& message)
-  {
-    if (HasGlobalContext())
-    {
-      OrthancPluginLogInfo(GetGlobalContext(), message.c_str());
-    }
-  }
-
-
   void OrthancConfiguration::LoadConfiguration()
   {
     OrthancString str;
@@ -723,7 +754,7 @@
 
     if (str.GetContent() == NULL)
     {
-      LogError("Cannot access the Orthanc configuration");
+      LOG_ERROR("Cannot access the Orthanc configuration");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -731,7 +762,7 @@
 
     if (configuration_.type() != Json::objectValue)
     {
-      LogError("Unable to read the Orthanc configuration");
+      LOG_ERROR("Unable to read the Orthanc configuration");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
   }
@@ -799,8 +830,8 @@
     {
       if (configuration_[key].type() != Json::objectValue)
       {
-        LogError("The configuration section \"" + target.path_ +
-                 "\" is not an associative array as expected");
+        LOG_ERROR("The configuration section \"" + target.path_ +
+                  "\" is not an associative array as expected");
 
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
       }
@@ -822,8 +853,8 @@
 
     if (configuration_[key].type() != Json::stringValue)
     {
-      LogError("The configuration option \"" + GetPath(key) +
-               "\" is not a string as expected");
+      LOG_ERROR("The configuration option \"" + GetPath(key) +
+                "\" is not a string as expected");
 
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -854,8 +885,8 @@
         return true;
 
       default:
-        LogError("The configuration option \"" + GetPath(key) +
-                 "\" is not an integer as expected");
+        LOG_ERROR("The configuration option \"" + GetPath(key) +
+                  "\" is not an integer as expected");
 
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -873,8 +904,8 @@
 
     if (tmp < 0)
     {
-      LogError("The configuration option \"" + GetPath(key) +
-               "\" is not a positive integer as expected");
+      LOG_ERROR("The configuration option \"" + GetPath(key) +
+                "\" is not a positive integer as expected");
 
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -898,8 +929,8 @@
 
     if (configuration_[key].type() != Json::booleanValue)
     {
-      LogError("The configuration option \"" + GetPath(key) +
-               "\" is not a Boolean as expected");
+      LOG_ERROR("The configuration option \"" + GetPath(key) +
+                "\" is not a Boolean as expected");
 
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -934,8 +965,8 @@
         return true;
 
       default:
-        LogError("The configuration option \"" + GetPath(key) +
-                 "\" is not an integer as expected");
+        LOG_ERROR("The configuration option \"" + GetPath(key) +
+                  "\" is not an integer as expected");
 
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -994,8 +1025,8 @@
         break;
     }
 
-    LogError("The configuration option \"" + GetPath(key) +
-             "\" is not a list of strings as expected");
+    LOG_ERROR("The configuration option \"" + GetPath(key) +
+              "\" is not a list of strings as expected");
 
     ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
   }
@@ -1115,8 +1146,8 @@
 
     if (configuration_[key].type() != Json::objectValue)
     {
-      LogError("The configuration option \"" + GetPath(key) +
-               "\" is not an object as expected");
+      LOG_ERROR("The configuration option \"" + GetPath(key) +
+                "\" is not an object as expected");
 
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
@@ -1133,8 +1164,8 @@
       }
       else
       {
-        LogError("The configuration option \"" + GetPath(key) +
-                 "\" is not a dictionary mapping strings to strings");
+        LOG_ERROR("The configuration option \"" + GetPath(key) +
+                  "\" is not a dictionary mapping strings to strings");
 
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
       }
@@ -1156,7 +1187,7 @@
   {
     if (image_ == NULL)
     {
-      LogError("Trying to access a NULL image");
+      LOG_ERROR("Trying to access a NULL image");
       ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
     }
   }
@@ -1182,7 +1213,7 @@
 
     if (image_ == NULL)
     {
-      LogError("Cannot create an image");
+      LOG_ERROR("Cannot create an image");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
   }
@@ -1199,7 +1230,7 @@
 
     if (image_ == NULL)
     {
-      LogError("Cannot create an image accessor");
+      LOG_ERROR("Cannot create an image accessor");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
   }
@@ -1213,7 +1244,7 @@
 
     if (image_ == NULL)
     {
-      LogError("Cannot uncompress a PNG image");
+      LOG_ERROR("Cannot uncompress a PNG image");
       ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
     }
   }
@@ -1226,7 +1257,7 @@
     image_ = OrthancPluginUncompressImage(GetGlobalContext(), data, size, OrthancPluginImageFormat_Jpeg);
     if (image_ == NULL)
     {
-      LogError("Cannot uncompress a JPEG image");
+      LOG_ERROR("Cannot uncompress a JPEG image");
       ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
     }
   }
@@ -1240,7 +1271,7 @@
     image_ = OrthancPluginDecodeDicomImage(GetGlobalContext(), data, size, frame);
     if (image_ == NULL)
     {
-      LogError("Cannot uncompress a DICOM image");
+      LOG_ERROR("Cannot uncompress a DICOM image");
       ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
     }
   }
@@ -1654,13 +1685,13 @@
                                    unsigned int minor,
                                    unsigned int revision)
   {
-    LogError("Your version of the Orthanc core (" +
-             std::string(GetGlobalContext()->orthancVersion) +
-             ") is too old to run this plugin (version " +
-             boost::lexical_cast<std::string>(major) + "." +
-             boost::lexical_cast<std::string>(minor) + "." +
-             boost::lexical_cast<std::string>(revision) +
-             " is required)");
+    LOG_ERROR("Your version of the Orthanc core (" +
+              std::string(GetGlobalContext()->orthancVersion) +
+              ") is too old to run this plugin (version " +
+              boost::lexical_cast<std::string>(major) + "." +
+              boost::lexical_cast<std::string>(minor) + "." +
+              boost::lexical_cast<std::string>(revision) +
+              " is required)");
   }
 
   bool CheckMinimalVersion(const char* version,
@@ -1740,7 +1771,7 @@
   {
     if (!HasGlobalContext())
     {
-      LogError("Bad Orthanc context in the plugin");
+      LOG_ERROR("Bad Orthanc context in the plugin");
       return false;
     }
 
@@ -1777,7 +1808,7 @@
     }
     else
     {
-      LogError("Inexistent peer: " + name);
+      LOG_ERROR("Inexistent peer: " + name);
       ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource);
     }
   }
@@ -2061,7 +2092,7 @@
 
     if (body.size() > 0xffffffffu)
     {
-      LogError("Cannot handle body size > 4GB");
+      LOG_ERROR("Cannot handle body size > 4GB");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -2098,7 +2129,7 @@
 
     if (body.size() > 0xffffffffu)
     {
-      LogError("Cannot handle body size > 4GB");
+      LOG_ERROR("Cannot handle body size > 4GB");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -2464,7 +2495,7 @@
 
     if (id == NULL)
     {
-      LogError("Plugin cannot submit job");
+      LOG_ERROR("Plugin cannot submit job");
       OrthancPluginFreeJob(GetGlobalContext(), orthanc);
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
     }
@@ -2533,7 +2564,7 @@
           throw Orthanc::OrthancException(static_cast<Orthanc::ErrorCode>(status["ErrorCode"].asInt()),
                                           status["ErrorDescription"].asString());
 #else
-          LogError("Exception while executing the job: " + status["ErrorDescription"].asString());
+          LOG_ERROR("Exception while executing the job: " + status["ErrorDescription"].asString());
           ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(status["ErrorCode"].asInt());          
 #endif
         }
@@ -2558,7 +2589,7 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
                                       "Expected a JSON object in the body");
 #else
-      LogError("Expected a JSON object in the body");
+      LOG_ERROR("Expected a JSON object in the body");
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
 #endif
     }
@@ -2574,7 +2605,7 @@
                                         "Option \"" + std::string(KEY_SYNCHRONOUS) +
                                         "\" must be Boolean");
 #else
-        LogError("Option \"" + std::string(KEY_SYNCHRONOUS) + "\" must be Boolean");
+        LOG_ERROR("Option \"" + std::string(KEY_SYNCHRONOUS) + "\" must be Boolean");
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
 #endif
       }
@@ -2593,7 +2624,7 @@
                                         "Option \"" + std::string(KEY_ASYNCHRONOUS) +
                                         "\" must be Boolean");
 #else
-        LogError("Option \"" + std::string(KEY_ASYNCHRONOUS) + "\" must be Boolean");
+        LOG_ERROR("Option \"" + std::string(KEY_ASYNCHRONOUS) + "\" must be Boolean");
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
 #endif
       }
@@ -2614,7 +2645,7 @@
                                         "Option \"" + std::string(KEY_PRIORITY) +
                                         "\" must be an integer");
 #else
-        LogError("Option \"" + std::string(KEY_PRIORITY) + "\" must be an integer");
+        LOG_ERROR("Option \"" + std::string(KEY_PRIORITY) + "\" must be an integer");
         ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
 #endif
       }
@@ -3135,7 +3166,7 @@
 
     if (body.size() > 0xffffffffu)
     {
-      LogError("Cannot handle body size > 4GB");
+      LOG_ERROR("Cannot handle body size > 4GB");
       ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
     }
 
@@ -3280,7 +3311,7 @@
     
     if (!ReadJson(answerBody, body))
     {
-      LogError("Cannot convert HTTP answer body to JSON");
+      LOG_ERROR("Cannot convert HTTP answer body to JSON");
       ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
@@ -4026,4 +4057,48 @@
       result[request->headersKeys[i]] = request->headersValues[i];
     }    
   }
+
+#if !ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+  static void SetPluginProperty(const std::string& pluginIdentifier,
+                                _OrthancPluginProperty property,
+                                const std::string& value)
+  {
+    _OrthancPluginSetPluginProperty params;
+    params.plugin = pluginIdentifier.c_str();
+    params.property = property;
+    params.value = value.c_str();
+
+    GetGlobalContext()->InvokeService(GetGlobalContext(), _OrthancPluginService_SetPluginProperty, &params);
+  }
+#endif
+
+  void SetRootUri(const std::string& pluginIdentifier,
+                  const std::string& uri)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginSetRootUri2(GetGlobalContext(), pluginIdentifier.c_str(), uri.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_RootUri, uri);
+#endif
+  }
+
+  void SetDescription(const std::string& pluginIdentifier,
+                      const std::string& description)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginSetDescription2(GetGlobalContext(), pluginIdentifier.c_str(), description.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_Description, description);
+#endif
+  }
+
+  void ExtendOrthancExplorer(const std::string& pluginIdentifier,
+                             const std::string& javascript)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginExtendOrthancExplorer2(GetGlobalContext(), pluginIdentifier.c_str(), javascript.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_OrthancExplorer, javascript);
+#endif
+  }
 }
--- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h	Wed Jan 24 13:28:34 2024 +0100
+++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h	Tue Apr 23 09:46:17 2024 +0200
@@ -2,8 +2,8 @@
  * Orthanc - A Lightweight, RESTful DICOM Store
  * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
  * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2023 Osimis S.A., Belgium
- * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ * Copyright (C) 2017-2024 Osimis S.A., Belgium
+ * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
  *
  * This program is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -137,6 +137,10 @@
 
   void SetGlobalContext(OrthancPluginContext* context);
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4)
+  void SetGlobalContext(OrthancPluginContext* context, const char* pluginName);
+#endif
+
   void ResetGlobalContext();
 
   bool HasGlobalContext();
@@ -637,11 +641,11 @@
   const char* AutodetectMimeType(const std::string& path);
 #endif
 
-  void LogError(const std::string& message);
+  void LogError(const std::string& message);   // From Orthanc 1.12.4, use LOG(ERROR) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext)
 
-  void LogWarning(const std::string& message);
+  void LogWarning(const std::string& message); // From Orthanc 1.12.4, use LOG(WARNING) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext)
 
-  void LogInfo(const std::string& message);
+  void LogInfo(const std::string& message);    // From Orthanc 1.12.4, use LOG(INFO) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext)
 
   void ReportMinimalOrthancVersion(unsigned int major,
                                    unsigned int minor,
@@ -1435,4 +1439,13 @@
                          IWebDavCollection& collection);
   };
 #endif
+
+  void SetRootUri(const std::string& pluginIdentifier,
+                  const std::string& uri);
+
+  void SetDescription(const std::string& pluginIdentifier,
+                      const std::string& description);
+
+  void ExtendOrthancExplorer(const std::string& pluginIdentifier,
+                             const std::string& javascript);
 }
--- a/TODO	Wed Jan 24 13:28:34 2024 +0100
+++ b/TODO	Tue Apr 23 09:46:17 2024 +0200
@@ -1,3 +1,9 @@
+* upgrade to SDK 1.12.4 to benefit from new logging primitives for plugins
+
+
+* https://orthanc.uclouvain.be/book/plugins/dicomweb.html#retrieving-dicom-resources-from-a-wado-rs-server
+  Retrieve shall return the list of orthanc IDs -> it is not !
+
 * when retrieving frames from Multi-frame instances, we should not transcode the whole instance for each frame !!!
   For a 90MB instance with 88 frames, OHIF is unusable because of this !
   Sample request: