Mercurial > hg > orthanc-databases
changeset 720:4c0dc2ad1d75 sql-opti
log-data-format option to get the log data in b64 (default) or json
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Mon, 11 Aug 2025 18:03:11 +0200 |
| parents | 9734488b55c0 |
| children | ca3d1f3a9412 |
| files | Framework/Plugins/DatabaseBackendAdapterV4.cpp |
| diffstat | 1 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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<uint64_t>(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);
