Mercurial > hg > orthanc-authorization
changeset 254:dabd229db543 inbox
use plugin SDK to record audit logs
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 15 Jul 2025 14:25:29 +0200 |
parents | b340ccd0b22a |
children | ccc1038b3b45 |
files | CMakeLists.txt Plugin/Plugin.cpp |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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<const void*>(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)