# HG changeset patch # User Alain Mazy # Date 1752582329 -7200 # Node ID dabd229db5437483bd6ccde3c29cac3bf7b4937e # Parent b340ccd0b22a76cc573f44edcb032efdcf52801e use plugin SDK to record audit logs diff -r b340ccd0b22a -r dabd229db543 CMakeLists.txt --- a/CMakeLists.txt Mon Jul 14 18:23:36 2025 +0200 +++ b/CMakeLists.txt Tue Jul 15 14:25:29 2025 +0200 @@ -88,6 +88,8 @@ include_directories(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-1.11.3) elseif (ORTHANC_SDK_VERSION STREQUAL "1.12.4") include_directories(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-1.12.4) + elseif (ORTHANC_SDK_VERSION STREQUAL "framework") + include_directories(${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include/) else() message(FATAL_ERROR "Unsupported version of the Orthanc plugin SDK: ${ORTHANC_SDK_VERSION}") endif() diff -r b340ccd0b22a -r dabd229db543 Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Mon Jul 14 18:23:36 2025 +0200 +++ b/Plugin/Plugin.cpp Tue Jul 15 14:25:29 2025 +0200 @@ -118,6 +118,24 @@ const Json::Value& logData) { LOG(WARNING) << "AUDIT-LOG: " << userId << " / " << action << " on " << resourceType << ":" << resourceId << ", " << logData.toStyledString(); + std::string serializedLogData; + const void* logDataPtr = NULL; + uint32_t logDataSize = 0; + + if (!logData.isNull()) + { + Orthanc::Toolbox::WriteFastJson(serializedLogData, logData); + logDataPtr = reinterpret_cast(serializedLogData.c_str()); + logDataSize = serializedLogData.size(); + } + + OrthancPluginRecordAuditLog(OrthancPlugins::GetGlobalContext(), + userId.c_str(), + resourceType, + resourceId.c_str(), + action.c_str(), + logDataPtr, + logDataSize); } static void RecordAuditLog(const AuditLog& auditLog)