# HG changeset patch # User Alain Mazy # Date 1754929302 -7200 # Node ID 94e3a3eac0f593395439cc85bb8a2752773f1903 # Parent 845c3dcb723e6ecd2a2efc89017c3535cb3ee31f# Parent 691af3fc15c5b4343c3b5a3c7e8f9c32fd00fd2d merge diff -r 691af3fc15c5 -r 94e3a3eac0f5 Framework/Plugins/BaseIndexConnectionsPool.cpp --- a/Framework/Plugins/BaseIndexConnectionsPool.cpp Mon Aug 11 17:50:58 2025 +0200 +++ b/Framework/Plugins/BaseIndexConnectionsPool.cpp Mon Aug 11 18:21:42 2025 +0200 @@ -28,25 +28,6 @@ namespace OrthancDatabases { -// class BaseIndexConnectionsPool::ManagerReference : public Orthanc::IDynamicObject -// { -// private: -// DatabaseManager* manager_; - -// public: -// explicit ManagerReference(DatabaseManager& manager) : -// manager_(&manager) -// { -// } - -// DatabaseManager& GetManager() -// { -// assert(manager_ != NULL); -// return *manager_; -// } -// }; - - void BaseIndexConnectionsPool::HousekeepingThread(BaseIndexConnectionsPool* that) { #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 2) @@ -134,7 +115,6 @@ BaseIndexConnectionsPool::Accessor::Accessor(BaseIndexConnectionsPool& pool) : - // lock_(pool.connectionsMutex_), pool_(pool), manager_(NULL) { @@ -155,11 +135,6 @@ { assert(manager_ != NULL); pool_.ReleaseConnection(manager_); - // boost::unique_lock lock(pool_.connectionsMutex_); - // pool_.availableConnections_.push_front(manager_); - // pool_.availableConnectionsSemaphore_.Release(1); - - } diff -r 691af3fc15c5 -r 94e3a3eac0f5 Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 17:50:58 2025 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 18:21:42 2025 +0200 @@ -1578,6 +1578,7 @@ uint64_t limit = 0; uint64_t fromTs = 0; uint64_t toTs = 0; + bool logDataInJson = false; if (getArguments.find("user-id") != getArguments.end()) { @@ -1614,6 +1615,11 @@ toTs = boost::lexical_cast(getArguments["to-timestamp"]); } + if (getArguments.find("log-data-format") != getArguments.end()) + { + logDataInJson = getArguments["log-data-format"] == "json"; + } + Json::Value jsonLogs; #if ORTHANC_PLUGINS_HAS_AUDIT_LOGS == 1 @@ -1667,17 +1673,35 @@ serializedAuditLog["ResourceType"] = level; - // TODO - Shouldn't the "LogData" information be Base64-encoded? - // Plugins are not required to write JSON (e.g., could be Protocol Buffers) - if (it->GetLogData().empty()) + if (logDataInJson) { - serializedAuditLog["LogData"] = Json::nullValue; + if (it->GetLogData().empty()) + { + serializedAuditLog["JsonLogData"] = Json::nullValue; + } + else + { + Json::Value logData; + if (Orthanc::Toolbox::ReadJson(logData, it->GetLogData())) + { + serializedAuditLog["JsonLogData"] = logData; + } + else // if the data is not json compatible, export it in b64 anyway + { + std::string b64logData; + Orthanc::Toolbox::EncodeBase64(b64logData, it->GetLogData()); + serializedAuditLog["Base64LogData"] = b64logData; + } + } } else { - Json::Value logData; - Orthanc::Toolbox::ReadJson(logData, it->GetLogData()); - serializedAuditLog["LogData"] = logData; + std::string b64logData; + if (!it->GetLogData().empty()) + { + Orthanc::Toolbox::EncodeBase64(b64logData, it->GetLogData()); + } + serializedAuditLog["Base64LogData"] = b64logData; } jsonLogs.append(serializedAuditLog); diff -r 691af3fc15c5 -r 94e3a3eac0f5 Framework/Plugins/DynamicIndexConnectionsPool.cpp --- a/Framework/Plugins/DynamicIndexConnectionsPool.cpp Mon Aug 11 17:50:58 2025 +0200 +++ b/Framework/Plugins/DynamicIndexConnectionsPool.cpp Mon Aug 11 18:21:42 2025 +0200 @@ -154,45 +154,4 @@ availableConnectionsSemaphore_.Release(1); } - // DynamicIndexConnectionsPool::Accessor::Accessor(DynamicIndexConnectionsPool& pool) : - // // lock_(pool.connectionsMutex_), - // pool_(pool), - // manager_(NULL) - // { - // for (;;) - // { - // std::unique_ptr manager(pool.GetConnection()); - // if (manager.get() != NULL) - // { - // manager_ = manager.release(); - // return; - // } - // boost::this_thread::sleep(boost::posix_time::millisec(100)); - // } - // } - - - // DynamicIndexConnectionsPool::Accessor::~Accessor() - // { - // assert(manager_ != NULL); - // pool_.ReleaseConnection(manager_); - // // boost::unique_lock lock(pool_.connectionsMutex_); - // // pool_.availableConnections_.push_front(manager_); - // // pool_.availableConnectionsSemaphore_.Release(1); - - - // } - - - // IndexBackend& DynamicIndexConnectionsPool::Accessor::GetBackend() const - // { - // return *pool_.backend_; - // } - - - // DatabaseManager& DynamicIndexConnectionsPool::Accessor::GetManager() const - // { - // assert(manager_ != NULL); - // return *manager_; - // } }