1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

Reuse normalizeException from NormalizerFormatter in JsonFormatter, fixes #1366

This commit is contained in:
Jordi Boggiano
2019-08-30 10:40:17 +02:00
parent acf8e9e9a3
commit 57b286f3d1

View File

@@ -166,24 +166,9 @@ class JsonFormatter extends NormalizerFormatter
*/ */
protected function normalizeException(Throwable $e, int $depth = 0): array protected function normalizeException(Throwable $e, int $depth = 0): array
{ {
$data = [ $data = parent::normalizeException($e, $depth);
'class' => Utils::getClass($e), if (!$this->includeStacktraces) {
'message' => $e->getMessage(), unset($data['trace']);
'code' => $e->getCode(),
'file' => $e->getFile().':'.$e->getLine(),
];
if ($this->includeStacktraces) {
$trace = $e->getTrace();
foreach ($trace as $frame) {
if (isset($frame['file'])) {
$data['trace'][] = $frame['file'].':'.$frame['line'];
}
}
}
if ($previous = $e->getPrevious()) {
$data['previous'] = $this->normalizeException($previous, $depth + 1);
} }
return $data; return $data;