Skip to content

Commit

Permalink
Change logic for logging responses to exclude the info log
Browse files Browse the repository at this point in the history
  • Loading branch information
Hectorhammett committed Sep 27, 2024
1 parent 600a947 commit 3cc71a4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/Logging/LoggingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,25 @@ private function logResponse(LogEvent $event): void
);
$this->logger->debug((string) json_encode($debugEvent));

$infoEvent = [
'timestamp' => $event->timestamp,
'severity' => LogLevel::INFO,
'clientId' => $event->clientId,
'requestId' => $event->requestId ?? null,
'jsonPayload' => [
'response.status' => $event->status
]
];

$infoEvent = array_filter($infoEvent, fn ($value) => !is_null($value));
$infoEvent['jsonPayload'] = array_filter(
$infoEvent['jsonPayload'],
fn ($value) => !is_null($value)
);

$this->logger->info((string) json_encode($infoEvent));
if ($event->status) {
$infoEvent = [
'timestamp' => $event->timestamp,
'severity' => LogLevel::INFO,
'clientId' => $event->clientId,
'requestId' => $event->requestId ?? null,
'jsonPayload' => [
'response.status' => $event->status
]
];

$infoEvent = array_filter($infoEvent, fn ($value) => !is_null($value));
$infoEvent['jsonPayload'] = array_filter(
$infoEvent['jsonPayload'],
fn ($value) => !is_null($value)
);

$this->logger->info((string) json_encode($infoEvent));
}
}

/**
Expand Down

0 comments on commit 3cc71a4

Please sign in to comment.