changeset 152:d62f52be1943

use Orthanc frameworking for logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 21 Jun 2024 11:22:57 +0200
parents 00cd1f01dd5d
children 6dd8bb916573
files Aws/AwsS3StoragePlugin.cpp Azure/AzureBlobStoragePlugin.cpp Common/BaseStorage.cpp Common/EncryptionConfigurator.cpp Common/FileSystemStorage.cpp Common/MoveStorageJob.cpp Common/StoragePlugin.cpp Google/GoogleStoragePlugin.cpp
diffstat 8 files changed, 101 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/Aws/AwsS3StoragePlugin.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Aws/AwsS3StoragePlugin.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -429,15 +429,15 @@
 
       if (logLevel == Aws::Utils::Logging::LogLevel::Debug || logLevel == Aws::Utils::Logging::LogLevel::Trace)
       {
-        LOG(INFO) << outputBuff.c_str();
+        LOG(INFO) << outputBuff;
       }
       else if (logLevel == Aws::Utils::Logging::LogLevel::Warn)
       {
-        LOG(WARNING) << outputBuff.c_str();
+        LOG(WARNING) << outputBuff;
       }
       else
       {
-        LOG(ERROR) << outputBuff.c_str();
+        LOG(ERROR) << outputBuff;
       }
 
       va_end(args);
@@ -479,7 +479,7 @@
 
   if (!orthancConfig.IsSection(GetConfigurationSectionName()))
   {
-    OrthancPlugins::LogWarning(std::string(GetStoragePluginName()) + " plugin, section missing.  Plugin is not enabled.");
+    LOG(WARNING) << GetStoragePluginName() << " plugin, section missing.  Plugin is not enabled.";
     return nullptr;
   }
 
@@ -498,13 +498,13 @@
 
   if (!pluginSection.LookupStringValue(bucketName, "BucketName"))
   {
-    OrthancPlugins::LogError("AwsS3Storage/BucketName configuration missing.  Unable to initialize plugin");
+    LOG(ERROR) << "AwsS3Storage/BucketName configuration missing.  Unable to initialize plugin";
     return nullptr;
   }
 
   if (!pluginSection.LookupStringValue(region, "Region"))
   {
-    OrthancPlugins::LogError("AwsS3Storage/Region configuration missing.  Unable to initialize plugin");
+    LOG(ERROR) << "AwsS3Storage/Region configuration missing.  Unable to initialize plugin";
     return nullptr;
   }
 
@@ -565,7 +565,7 @@
 
     if (pluginSection.LookupStringValue(accessKey, "AccessKey") && pluginSection.LookupStringValue(secretKey, "SecretKey"))
     {
-      OrthancPlugins::LogInfo("AWS S3 Storage: using credentials from the configuration file");
+      LOG(INFO) << "AWS S3 Storage: using credentials from the configuration file";
       Aws::Auth::AWSCredentials credentials(accessKey.c_str(), secretKey.c_str());
       
       client = Aws::MakeShared<Aws::S3::S3Client>(ALLOCATION_TAG, credentials, configuration, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, virtualAddressing);
@@ -573,18 +573,18 @@
     else
     {
       // when using default credentials, credentials are not checked at startup but only the first time you try to access the bucket !
-      OrthancPlugins::LogInfo("AWS S3 Storage: using default credentials provider");
+      LOG(INFO) << "AWS S3 Storage: using default credentials provider";
       client = Aws::MakeShared<Aws::S3::S3Client>(ALLOCATION_TAG, configuration, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, virtualAddressing);
     }  
 
-    OrthancPlugins::LogInfo("AWS S3 storage initialized");
+    LOG(INFO) << "AWS S3 storage initialized";
 
     return new AwsS3StoragePlugin(nameForLogs, client, bucketName, enableLegacyStorageStructure, storageContainsUnknownFiles, useTransferManager, transferPoolSize, transferBufferSizeMB);
   }
   catch (const std::exception& e)
   {
     Aws::ShutdownAPI(*sdkOptions_);
-    OrthancPlugins::LogError(std::string("AWS S3 Storage plugin: failed to initialize plugin: ") + e.what());
+    LOG(ERROR) << "AWS S3 Storage plugin: failed to initialize plugin: " << e.what();
     return nullptr;
   }
 }
--- a/Azure/AzureBlobStoragePlugin.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Azure/AzureBlobStoragePlugin.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -27,6 +27,8 @@
 // #include "cpprest/rawptrstream.h"
 // #include "cpprest/details/basic_types.h"
 
+#include <Logging.h>
+
 // Create aliases to make the code easier to read.
 namespace as = Azure::Storage::Blobs;
 
@@ -224,13 +226,13 @@
 
     if (!pluginSection.LookupStringValue(connectionString, "ConnectionString"))
     {
-      OrthancPlugins::LogError("AzureBlobStorage/ConnectionString configuration missing.  Unable to initialize plugin");
+      LOG(ERROR) << "AzureBlobStorage/ConnectionString configuration missing.  Unable to initialize plugin";
       return nullptr;
     }
 
     if (!pluginSection.LookupStringValue(containerName, "ContainerName"))
     {
-      OrthancPlugins::LogError("AzureBlobStorage/ContainerName configuration missing.  Unable to initialize plugin");
+      LOG(ERROR) << "AzureBlobStorage/ContainerName configuration missing.  Unable to initialize plugin";
       return nullptr;
     }
 
@@ -241,7 +243,7 @@
   }
   else if (orthancConfig.IsSection("BlobStorage")) // backward compatibility with the old plugin:
   {
-    OrthancPlugins::LogWarning("AzureBlobStorage: you're using an old configuration format for the plugin.");
+    LOG(WARNING) << "AzureBlobStorage: you're using an old configuration format for the plugin.";
 
     OrthancPlugins::OrthancConfiguration pluginSection;
     orthancConfig.GetSection(pluginSection, "BlobStorage");
@@ -251,19 +253,19 @@
 
     if (!pluginSection.LookupStringValue(containerName, "ContainerName"))
     {
-      OrthancPlugins::LogError("BlobStorage/AccountName configuration missing.  Unable to initialize plugin");
+      LOG(ERROR) << "BlobStorage/AccountName configuration missing.  Unable to initialize plugin";
       return nullptr;
     }
 
     if (!pluginSection.LookupStringValue(accountName, "AccountName"))
     {
-      OrthancPlugins::LogError("BlobStorage/AccountName configuration missing.  Unable to initialize plugin");
+      LOG(ERROR) << "BlobStorage/AccountName configuration missing.  Unable to initialize plugin";
       return nullptr;
     }
 
     if (!pluginSection.LookupStringValue(accountKey, "AccountKey"))
     {
-      OrthancPlugins::LogError("BlobStorage/ContainerName configuration missing.  Unable to initialize plugin");
+      LOG(ERROR) << "BlobStorage/ContainerName configuration missing.  Unable to initialize plugin";
       return nullptr;
     }
 
@@ -275,16 +277,16 @@
   }
   else
   {
-    OrthancPlugins::LogWarning(std::string(GetStoragePluginName()) + " plugin, section missing.  Plugin is not enabled.");
+    LOG(WARNING) << GetStoragePluginName() << " plugin, section missing.  Plugin is not enabled.";
     return nullptr;
   }
 
   try
   {
-    OrthancPlugins::LogInfo("Connecting to Azure storage ...");
+    LOG(INFO) << "Connecting to Azure storage ...";
 
     as::BlobContainerClient client = as::BlobContainerClient::CreateFromConnectionString(connectionString, containerName);
-    OrthancPlugins::LogInfo("Blob client created");
+    LOG(INFO) << "Blob client created";
 
     if (createContainerIfNotExists)
     {
@@ -300,17 +302,17 @@
       auto createResult = client.CreateIfNotExists();
       if (createResult.Value.Created)
       {
-        OrthancPlugins::LogWarning("Blob Storage Area container has been created.  **** check in the Azure console that your container is private ****");
+        LOG(WARNING) << "Blob Storage Area container has been created.  **** check in the Azure console that your container is private ****";
       }
     }
 
-    OrthancPlugins::LogInfo("Blob storage initialized");
+    LOG(INFO) << "Blob storage initialized";
 
     return new AzureBlobStoragePlugin(nameForLogs, client, enableLegacyStorageStructure, storageContainsUnknownFiles);
   }
   catch (const std::exception& e)
   {
-    OrthancPlugins::LogError(std::string("AzureBlobStorage plugin: failed to initialize plugin: ") + e.what());
+    LOG(ERROR) << "AzureBlobStorage plugin: failed to initialize plugin: " << e.what();
     return nullptr;
   }
 
--- a/Common/BaseStorage.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Common/BaseStorage.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -20,6 +20,9 @@
 
 
 #include "BaseStorage.h"
+
+#include <Logging.h>
+
 #include <boost/filesystem/fstream.hpp>
 
 boost::filesystem::path BaseStorage::GetOrthancFileSystemPath(const std::string& uuid, const std::string& fileSystemRootPath)
@@ -86,7 +89,7 @@
     enableLegacyStorageStructure = true;
     if (storageStructure != "legacy")
     {
-      OrthancPlugins::LogError("ObjectStorage/StorageStructure configuration invalid value: " + storageStructure + ", allowed values are 'flat' and 'legacy'");
+      LOG(ERROR) << "ObjectStorage/StorageStructure configuration invalid value: " << storageStructure << ", allowed values are 'flat' and 'legacy'";
       return false;
     }
   }
--- a/Common/EncryptionConfigurator.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Common/EncryptionConfigurator.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -24,11 +24,13 @@
 
 #include "EncryptionConfigurator.h"
 
+#include <Logging.h>
+
 bool ReadMasterKey(uint32_t& id, std::string& keyPath, const Json::Value& node)
 {
   if (!node.isArray() || node.size() != 2 || !node[0].isUInt() || !node[1].isString())
   {
-    OrthancPlugins::LogWarning("Encryption: Invalid master key configuration");
+    LOG(WARNING) << "Encryption: Invalid master key configuration";
     return false;
   }
 
@@ -52,7 +54,7 @@
 
   if (!cryptoJson.isMember("MasterKey") || !cryptoJson["MasterKey"].isArray())
   {
-    OrthancPlugins::LogWarning("Encryption: MasterKey missing.  Unable to initialize encryption");
+    LOG(WARNING) << "Encryption: MasterKey missing.  Unable to initialize encryption";
     return nullptr;
   }
 
--- a/Common/FileSystemStorage.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Common/FileSystemStorage.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -21,7 +21,9 @@
 #include "FileSystemStorage.h"
 #include "BaseStorage.h"
 
+#include <Logging.h>
 #include <SystemToolbox.h>
+
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 
@@ -143,7 +145,7 @@
   }
   catch(Orthanc::OrthancException& e)
   {
-    OrthancPlugins::LogError(GetNameForLogs() + ": error while deleting object " + std::string(uuid) + ": " + std::string(e.What()));
+    LOG(ERROR) << GetNameForLogs() << ": error while deleting object " << uuid << ": " << e.What();
   }
 
 }
--- a/Common/MoveStorageJob.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Common/MoveStorageJob.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -71,17 +71,20 @@
   {
     if (sourceStorage->HasFileExists() && !sourceStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled))
     {
-      OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file is not on the source anymore");
+      LOG(INFO) << "Move attachment: " << sourceStorage->GetNameForLogs() << " " << uuid
+                << " of type " << boost::lexical_cast<std::string>(type) << ", skipping, file is not on the source anymore";
       return true;
     }
     else if (targetStorage->HasFileExists() && targetStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled))
     {
-      OrthancPlugins::LogInfo("Move attachment: " + targetStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file already on the target");
+      LOG(INFO) << "Move attachment: " << targetStorage->GetNameForLogs() << " " << uuid
+                << " of type " << boost::lexical_cast<std::string>(type) << ", skipping, file already on the target";
       return true;
     }
     else
     {
-      OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
+      LOG(INFO) << "Move attachment: " << sourceStorage->GetNameForLogs() << ": reading attachment "
+                << uuid << " of type " << boost::lexical_cast<std::string>(type);
     }
 
     std::unique_ptr<IStorage::IReader> reader(sourceStorage->GetReaderForObject(uuid.c_str(), static_cast<OrthancPluginContentType>(type), cryptoEnabled));
@@ -93,7 +96,8 @@
   }
   catch (StoragePluginException& ex)
   {
-    OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": error while reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", this likely means that the file is already on the right storage");
+    LOG(INFO) << "Move attachment: " << sourceStorage->GetNameForLogs() << ": error while reading attachment " << uuid
+              << " of type " << boost::lexical_cast<std::string>(type) << ", this likely means that the file is already on the right storage";
     return true;
   }
 
@@ -108,7 +112,8 @@
     }
     catch (StoragePluginException& ex)
     {
-      OrthancPlugins::LogError("Move attachment: " + targetStorage->GetNameForLogs() + ": error while writing attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ": " + ex.what());
+      LOG(ERROR) << "Move attachment: " << targetStorage->GetNameForLogs() << ": error while writing attachment "
+                 << uuid << " of type " << boost::lexical_cast<std::string>(type) << ": " << ex.what();
       return false;
     }
   }
@@ -122,7 +127,8 @@
     }
     catch (StoragePluginException& ex)
     {
-      OrthancPlugins::LogError("Move attachment: " + sourceStorage->GetNameForLogs() + ": error while deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ": " + ex.what());
+      LOG(ERROR) << "Move attachment: " << sourceStorage->GetNameForLogs() << ": error while deleting attachment "
+                 << uuid << " of type " << boost::lexical_cast<std::string>(type) << ": " << ex.what();
       return false;
     }
   }
--- a/Common/StoragePlugin.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Common/StoragePlugin.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -81,6 +81,16 @@
 
 typedef void LogErrorFunction(const std::string& message);
 
+static void LogErrorAsWarning(const std::string& message)
+{
+  LOG(WARNING) << message;
+}
+
+static void LogErrorAsError(const std::string& message)
+{
+  LOG(ERROR) << message;
+}
+
 
 
 static OrthancPluginErrorCode StorageCreate(const char* uuid,
@@ -91,7 +101,8 @@
   try
   {
     Orthanc::Toolbox::ElapsedTimer timer;
-    OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
+    LOG(INFO) << primaryStorage->GetNameForLogs() << ": creating attachment " << uuid
+              << " of type " << boost::lexical_cast<std::string>(type);
     std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled));
 
     if (cryptoEnabled)
@@ -104,7 +115,7 @@
       }
       catch (EncryptionException& ex)
       {
-        OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while encrypting object " + std::string(uuid) + ": " + ex.what());
+        LOG(ERROR) << primaryStorage->GetNameForLogs() << ": error while encrypting object " << uuid << ": " << ex.what();
         return OrthancPluginErrorCode_StorageAreaPlugin;
       }
 
@@ -114,11 +125,12 @@
     {
       writer->Write(reinterpret_cast<const char*>(content), size);
     }
-    OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": created attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, size) + ")");
+    LOG(INFO) << primaryStorage->GetNameForLogs() << ": created attachment " << uuid
+              << " (" << timer.GetHumanTransferSpeed(true, size) << ")";
   }
   catch (StoragePluginException& ex)
   {
-    OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what());
+    LOG(ERROR) << primaryStorage->GetNameForLogs() << ": error while creating object " << uuid << ": " << ex.what();
     return OrthancPluginErrorCode_StorageAreaPlugin;
   }
 
@@ -138,12 +150,14 @@
   try
   {
     Orthanc::Toolbox::ElapsedTimer timer;
-    OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
+    LOG(INFO) << storage->GetNameForLogs() << ": reading range of attachment " << uuid
+              << " of type " << boost::lexical_cast<std::string>(type);
     
     std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled));
     reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart);
     
-    OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read range of attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, target->size) + ")");
+    LOG(INFO) << storage->GetNameForLogs() << ": read range of attachment " << uuid
+              << " (" << timer.GetHumanTransferSpeed(true, target->size) << ")";
     return OrthancPluginErrorCode_Success;
   }
   catch (StoragePluginException& ex)
@@ -159,7 +173,7 @@
                                                uint64_t rangeStart)
 {
   OrthancPluginErrorCode res = StorageReadRange(primaryStorage.get(),
-                                                (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
+                                                (IsHybridModeEnabled() ? LogErrorAsWarning : LogErrorAsError), // log errors as warning on first try
                                                 target,
                                                 uuid,
                                                 type,
@@ -168,7 +182,7 @@
   if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
   {
     res = StorageReadRange(secondaryStorage.get(),
-                           OrthancPlugins::LogError, // log errors as errors on second try
+                           LogErrorAsError, // log errors as errors on second try
                            target,
                            uuid,
                            type,
@@ -188,7 +202,8 @@
   try
   {
     Orthanc::Toolbox::ElapsedTimer timer;
-    OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
+    LOG(INFO) << storage->GetNameForLogs() << ": reading whole attachment " << uuid
+              << " of type " << boost::lexical_cast<std::string>(type);
     std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled));
 
     size_t fileSize = reader->GetSize();
@@ -235,7 +250,8 @@
       reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize);
     }
 
-    OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read whole attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, fileSize) + ")");
+    LOG(INFO) << storage->GetNameForLogs() << ": read whole attachment " << uuid
+              << " (" << timer.GetHumanTransferSpeed(true, fileSize) << ")";
   }
   catch (StoragePluginException& ex)
   {
@@ -251,7 +267,7 @@
                                                OrthancPluginContentType type)
 {
   OrthancPluginErrorCode res = StorageReadWhole(primaryStorage.get(),
-                                                (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
+                                                (IsHybridModeEnabled() ? LogErrorAsWarning : LogErrorAsError), // log errors as warning on first try
                                                 target,
                                                 uuid,
                                                 type);
@@ -259,7 +275,7 @@
   if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
   {
     res = StorageReadWhole(secondaryStorage.get(),
-                           OrthancPlugins::LogError, // log errors as errors on second try
+                           LogErrorAsError, // log errors as errors on second try
                            target,
                            uuid,
                            type);
@@ -292,7 +308,8 @@
 {
   try
   {
-    OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
+    LOG(INFO) << storage->GetNameForLogs() << ": deleting attachment " << uuid
+              << " of type " << boost::lexical_cast<std::string>(type);
     storage->DeleteObject(uuid, type, cryptoEnabled);
     if ((storage == primaryStorage.get()) && IsHybridModeEnabled())
     {
@@ -313,14 +330,14 @@
                                             OrthancPluginContentType type)
 {
   OrthancPluginErrorCode res = StorageRemove(primaryStorage.get(),
-                                             (IsHybridModeEnabled() ? OrthancPlugins::LogWarning : OrthancPlugins::LogError), // log errors as warning on first try
+                                             (IsHybridModeEnabled() ? LogErrorAsWarning : LogErrorAsError), // log errors as warning on first try
                                              uuid,
                                              type);
 
   if (res != OrthancPluginErrorCode_Success && IsHybridModeEnabled())
   {
     res = StorageRemove(secondaryStorage.get(),
-                        OrthancPlugins::LogError, // log errors as errors on second try
+                        LogErrorAsError, // log errors as errors on second try
                         uuid,
                         type);
   }
@@ -452,7 +469,7 @@
     }   
   }
 
-  OrthancPlugins::LogInfo("Moving " + boost::lexical_cast<std::string>(instances.size()) + " instances to " + targetStorage);
+  LOG(INFO) << "Moving " << instances.size() << " instances to " << targetStorage;
 
   std::unique_ptr<MoveStorageJob> job(CreateMoveStorageJob(targetStorage, instances, resourcesForJobContent));
 
@@ -547,7 +564,7 @@
               ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
               ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
               ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
-      OrthancPlugins::LogError(info);
+      LOG(ERROR) << info;
       return -1;
     }
 
@@ -555,7 +572,7 @@
 
     OrthancPlugins::OrthancConfiguration orthancConfig;
 
-    OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is initializing");
+    LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << " plugin is initializing";
     OrthancPlugins::SetDescription(StoragePluginFactory::GetStoragePluginName(), StoragePluginFactory::GetStorageDescription());
 
     try
@@ -565,7 +582,8 @@
 
       if (!orthancConfig.IsSection(pluginSectionName))
       {
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": no \"" + pluginSectionName +  "\" section found in configuration, plugin is disabled");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": no \"" << pluginSectionName
+                     << "\" section found in configuration, plugin is disabled";
         return 0;
       }
 
@@ -578,34 +596,34 @@
       if (migrationFromFileSystemEnabled && hybridModeString == "Disabled")
       {
         hybridMode = HybridMode_WriteToObjectStorage;
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": 'MigrationFromFileSystemEnabled' configuration is deprecated, use 'HybridMode': 'WriteToObjectStorage' instead");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": 'MigrationFromFileSystemEnabled' configuration is deprecated, use 'HybridMode': 'WriteToObjectStorage' instead";
       }
       else if (hybridModeString == "WriteToObjectStorage")
       {
         hybridMode = HybridMode_WriteToObjectStorage;
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": WriteToObjectStorage HybridMode is enabled: writing to object-storage, try reading first from object-storage and, then, from file system");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": WriteToObjectStorage HybridMode is enabled: writing to object-storage, try reading first from object-storage and, then, from file system";
       }
       else if (hybridModeString == "WriteToFileSystem")
       {
         hybridMode = HybridMode_WriteToFileSystem;
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": WriteToFileSystem HybridMode is enabled: writing to file system, try reading first from file system and, then, from object-storage");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": WriteToFileSystem HybridMode is enabled: writing to file system, try reading first from file system and, then, from object-storage";
       }
       else
       {
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode is disabled: writing to object-storage and reading only from object-storage");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": HybridMode is disabled: writing to object-storage and reading only from object-storage";
       }
 
       if (IsReadFromDisk())
       {
         fileSystemRootPath = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorageNotDefined");
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": HybridMode: reading from file system is enabled, source: " + fileSystemRootPath);
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": HybridMode: reading from file system is enabled, source: " << fileSystemRootPath;
       }
 
       objectsRootPath = pluginSection.GetStringValue("RootPath", std::string());
 
       if (objectsRootPath.size() >= 1 && objectsRootPath[0] == '/')
       {
-        OrthancPlugins::LogError(std::string(StoragePluginFactory::GetStoragePluginName()) + ": The RootPath shall not start with a '/': " + objectsRootPath);
+        LOG(ERROR) << StoragePluginFactory::GetStoragePluginName() << ": The RootPath shall not start with a '/': " << objectsRootPath;
         return -1;
       }
 
@@ -672,11 +690,11 @@
 
       if (cryptoEnabled)
       {
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is enabled");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": client-side encryption is enabled";
       }
       else
       {
-        OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is disabled");
+        LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << ": client-side encryption is disabled";
       }
 
 
@@ -708,7 +726,7 @@
 
   ORTHANC_PLUGINS_API void OrthancPluginFinalize()
   {
-    OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is finalizing");
+    LOG(WARNING) << StoragePluginFactory::GetStoragePluginName() << " plugin is finalizing";
     primaryStorage.reset();
     secondaryStorage.reset();
     Orthanc::FinalizeFramework();
--- a/Google/GoogleStoragePlugin.cpp	Fri Jun 21 10:29:52 2024 +0200
+++ b/Google/GoogleStoragePlugin.cpp	Fri Jun 21 11:22:57 2024 +0200
@@ -23,6 +23,8 @@
 
 #include "google/cloud/storage/client.h"
 
+#include <Logging.h>
+
 // Create aliases to make the code easier to read.
 namespace gcs = google::cloud::storage;
 
@@ -223,7 +225,7 @@
     }
     else
     {
-        throw StoragePluginException("error while getting the size of " + std::string(path) + ": " + objectMetadata.status().message());
+      throw StoragePluginException("error while getting the size of " + std::string(path) + ": " + objectMetadata.status().message());
     }
   }
 
@@ -248,7 +250,7 @@
 
   if (!orthancConfig.IsSection(GetConfigurationSectionName()))
   {
-    OrthancPlugins::LogWarning(std::string(GetStoragePluginName()) + " plugin, section missing.  Plugin is not enabled.");
+    LOG(WARNING) << GetStoragePluginName() << " plugin, section missing.  Plugin is not enabled.";
     return nullptr;
   }
 
@@ -264,14 +266,14 @@
 
   if (!pluginSection.LookupStringValue(pathToGoogleCredentials, "ServiceAccountFile"))
   {
-    OrthancPlugins::LogError("GoogleCloudStorage/ServiceAccountFile configuration missing.  Unable to initialize plugin");
+    LOG(ERROR) << "GoogleCloudStorage/ServiceAccountFile configuration missing.  Unable to initialize plugin";
     return nullptr;
   }
 
   std::string googleBucketName;
   if (!pluginSection.LookupStringValue(googleBucketName, "BucketName"))
   {
-    OrthancPlugins::LogError("GoogleCloudStorage/BucketName configuration missing.  Unable to initialize plugin");
+    LOG(ERROR) << "GoogleCloudStorage/BucketName configuration missing.  Unable to initialize plugin";
     return nullptr;
   }
 
@@ -279,7 +281,7 @@
   auto creds = gcs::oauth2::CreateServiceAccountCredentialsFromJsonFilePath(pathToGoogleCredentials);
   if (!creds)
   {
-    OrthancPlugins::LogError("GoogleCloudStorage plugin: unable to validate credentials.  Check the ServiceAccountFile: " + creds.status().message());
+    LOG(ERROR) << "GoogleCloudStorage plugin: unable to validate credentials.  Check the ServiceAccountFile: " << creds.status().message();
     return nullptr;
   }
 
@@ -288,7 +290,7 @@
 
   if (!mainClient)
   {
-    OrthancPlugins::LogError("GoogleCloudStorage plugin: unable to create client: " + mainClient.status().message());
+    LOG(ERROR) << "GoogleCloudStorage plugin: unable to create client: " << mainClient.status().message();
     return nullptr;
   }