Skip to content

Commit 26a4972

Browse files
committed
fix(logger): Fix calls to log normalizer
Signed-off-by: Joas Schilling <[email protected]>
1 parent 0ad1141 commit 26a4972

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/private/Log.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ public function logException(Throwable $exception, array $context = []): void {
342342
$this->error('Failed to load ExceptionSerializer serializer while trying to log ' . $exception->getMessage());
343343
return;
344344
}
345+
346+
$context = array_map($this->normalizer->format(...), $context);
345347
$data = $context;
346-
unset($data['app']);
347-
unset($data['level']);
348+
unset($data['app'], $data['level']);
349+
348350
$data = array_merge($serializer->serializeException($exception), $data);
349351
$data = $this->interpolateMessage($data, isset($context['message']) && $context['message'] !== '' ? $context['message'] : ('Exception thrown: ' . get_class($exception)), 'CustomMessage');
350352

351-
array_walk($context, [$this->normalizer, 'format']);
352-
353353
$this->eventDispatcher?->dispatchTyped(new BeforeMessageLoggedEvent($app, $level, $data));
354354

355355
try {
@@ -374,8 +374,7 @@ public function logData(string $message, array $data, array $context = []): void
374374
$level = $context['level'] ?? ILogger::ERROR;
375375

376376
$minLevel = $this->getLogLevel($context, $message);
377-
378-
array_walk($context, [$this->normalizer, 'format']);
377+
$data = array_map($this->normalizer->format(...), $data);
379378

380379
try {
381380
if ($level >= $minLevel) {
@@ -385,8 +384,6 @@ public function logData(string $message, array $data, array $context = []): void
385384
}
386385
$this->writeLog($app, $data, $level);
387386
}
388-
389-
$context['level'] = $level;
390387
} catch (Throwable $e) {
391388
// make sure we dont hard crash if logging fails
392389
error_log('Error when trying to log exception: ' . $e->getMessage() . ' ' . $e->getTraceAsString());

0 commit comments

Comments
 (0)