# HG changeset patch # User Alain Mazy # Date 1754928191 -7200 # Node ID 4c0dc2ad1d7586dfe4fca104b974cead2208b481 # Parent 9734488b55c0b9be20e7349e5bb3cf27725a2eaf log-data-format option to get the log data in b64 (default) or json diff -r 9734488b55c0 -r 4c0dc2ad1d75 Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 15:20:16 2025 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 18:03:11 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 @@ -1669,15 +1675,27 @@ // 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["LogData"] = Json::nullValue; + } + else + { + Json::Value logData; + Orthanc::Toolbox::ReadJson(logData, it->GetLogData()); + serializedAuditLog["LogData"] = logData; + } } 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["LogData"] = b64logData; } jsonLogs.append(serializedAuditLog);