From 087d0b4386da03d553ad4fe3651ad840670b0be4 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Wed, 6 Jun 2018 16:22:35 +0200 Subject: [PATCH] Added the context for php errors --- src/Formatter/HumanReadableExceptionFormatter.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Formatter/HumanReadableExceptionFormatter.php b/src/Formatter/HumanReadableExceptionFormatter.php index e654cd5..67ef48a 100644 --- a/src/Formatter/HumanReadableExceptionFormatter.php +++ b/src/Formatter/HumanReadableExceptionFormatter.php @@ -33,6 +33,21 @@ public function format(array $record): string $record['message'] ); + if (isset($record['context']['file'])) { + $result .= "[Context]\n\n"; + + if (isset($record['context']['message'])) { + $result .= sprintf(" Message: %s\n", $record['context']['message']); + } + + $result .= sprintf(" File: %s\n", $record['context']['file']); + $result .= sprintf(" Line: %d\n", $record['context']['line']); + + if (isset($record['context']['code'])) { + $result .= sprintf(" Code: %s\n\n", $record['context']['code']); + } + } + $exceptionCounter = 1; while ($throwable !== null) {