mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 17:16:18 +02:00
Json formatter should always format context/extra as an object, fixes #1028
This commit is contained in:
@@ -64,7 +64,15 @@ class JsonFormatter extends NormalizerFormatter
|
||||
*/
|
||||
public function format(array $record): string
|
||||
{
|
||||
return $this->toJson($this->normalize($record), true) . ($this->appendNewline ? "\n" : '');
|
||||
$normalized = $this->normalize($record);
|
||||
if (isset($normalized['context']) && $normalized['context'] === []) {
|
||||
$normalized['context'] = new \stdClass;
|
||||
}
|
||||
if (isset($normalized['extra']) && $normalized['extra'] === []) {
|
||||
$normalized['extra'] = new \stdClass;
|
||||
}
|
||||
|
||||
return $this->toJson($normalized, true) . ($this->appendNewline ? "\n" : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user