1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 12:47: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
{
$data = [
'class' => Utils::getClass($e),
'message' => $e->getMessage(),
'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);
$data = parent::normalizeException($e, $depth);
if (!$this->includeStacktraces) {
unset($data['trace']);
}
return $data;