changeset 5563:e02cdf358905

fix plugin init wrt logging
author Alain Mazy <am@orthanc.team>
date Tue, 23 Apr 2024 10:26:48 +0200
parents 0b18690c1935
children e791a74ea946
files OrthancFramework/Sources/Logging.cpp OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp
diffstat 6 files changed, 10 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -913,7 +913,7 @@
       
           if (loggingStreamsContext_.get() == NULL)
           {
-            fprintf(stderr, "ERROR: Trying to log a message after the finalization of the logging engine\n");
+            fprintf(stderr, "ERROR: Trying to log a message after the finalization of the logging engine (or did you forgot to initialize it ?)\n"); // have you called Orthanc::Logging::InitializePluginContext ?
             lock_.unlock();
             return;
           }
--- a/OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -289,8 +289,8 @@
 {
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
   {
-    OrthancPlugins::SetGlobalContext(context);
-    Orthanc::Logging::InitializePluginContext(context);
+    OrthancPlugins::SetGlobalContext(context, ORTHANC_PLUGIN_NAME);
+    Orthanc::Logging::InitializePluginContext(context, ORTHANC_PLUGIN_NAME);
     
 
     /* Check the version of the Orthanc core */
--- a/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -795,7 +795,8 @@
 
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
   {
-    OrthancPlugins::SetGlobalContext(c);
+    OrthancPlugins::SetGlobalContext(c, HOUSEKEEPER_NAME);
+    Orthanc::Logging::InitializePluginContext(c, HOUSEKEEPER_NAME);
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(c) == 0)
--- a/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -214,7 +214,8 @@
 {
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
   {
-    OrthancPlugins::SetGlobalContext(c);
+    Orthanc::Logging::InitializePluginContext(c, MODALITY_WORKLISTS_NAME);
+    OrthancPlugins::SetGlobalContext(c, MODALITY_WORKLISTS_NAME);
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(c) == 0)
--- a/OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -121,6 +121,7 @@
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
   {
     OrthancPlugins::SetGlobalContext(context, ORTHANC_PLUGIN_NAME);
+    Orthanc::Logging::InitializePluginContext(context, ORTHANC_PLUGIN_NAME);
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(OrthancPlugins::GetGlobalContext()) == 0)
@@ -135,18 +136,6 @@
       return -1;
     }
 
-#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2)
-    Orthanc::Logging::InitializePluginContext(context);
-#else
-    Orthanc::Logging::Initialize(context);
-#endif
-
-    if (!OrthancPlugins::CheckMinimalOrthancVersion(1, 12, 4))
-    {
-      OrthancPlugins::ReportMinimalOrthancVersion(1, 12, 4);
-      return -1;
-    }
-
     OrthancPluginSetDescription2(context, ORTHANC_PLUGIN_NAME, "Multitenant plugin for Orthanc.");
 
     OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
--- a/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Tue Apr 23 09:34:02 2024 +0200
+++ b/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Tue Apr 23 10:26:48 2024 +0200
@@ -416,7 +416,8 @@
 {
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
   {
-    OrthancPlugins::SetGlobalContext(context);
+    OrthancPlugins::SetGlobalContext(context, SERVE_FOLDERS_NAME);
+    Orthanc::Logging::InitializePluginContext(context, SERVE_FOLDERS_NAME);
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(context) == 0)