Mercurial > hg > orthanc-databases
changeset 721:ca3d1f3a9412 sql-opti
log-data-format option to get the log data in b64 (default) or json (cont)
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 11 Aug 2025 18:11:09 +0200 |
parents | 4c0dc2ad1d75 |
children | 845c3dcb723e |
files | Framework/Plugins/DatabaseBackendAdapterV4.cpp |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 18:03:11 2025 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Aug 11 18:11:09 2025 +0200 @@ -1673,19 +1673,25 @@ 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 (logDataInJson) { if (it->GetLogData().empty()) { - serializedAuditLog["LogData"] = Json::nullValue; + serializedAuditLog["JsonLogData"] = Json::nullValue; } else { Json::Value logData; - Orthanc::Toolbox::ReadJson(logData, it->GetLogData()); - serializedAuditLog["LogData"] = 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 @@ -1695,7 +1701,7 @@ { Orthanc::Toolbox::EncodeBase64(b64logData, it->GetLogData()); } - serializedAuditLog["LogData"] = b64logData; + serializedAuditLog["Base64LogData"] = b64logData; } jsonLogs.append(serializedAuditLog);