fix(log): Only log client request id if present, and at the end

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2025-05-13 11:18:20 +02:00 committed by Côme Chilliet
parent 4c25654574
commit 2b4bfcc212

View file

@ -46,10 +46,8 @@ abstract class LogDetails {
$userAgent = '--';
}
$version = $this->config->getValue('version', '');
$clientReqId = $request->getHeader('X-Request-Id');
$entry = compact(
'reqId',
'clientReqId',
'level',
'time',
'remoteAddr',
@ -61,6 +59,10 @@ abstract class LogDetails {
'userAgent',
'version'
);
$clientReqId = $request->getHeader('X-Request-Id');
if ($clientReqId !== '') {
$entry['clientReqId'] = $clientReqId;
}
if (is_array($message)) {
// Exception messages are extracted and the exception is put into a separate field