@@ -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