Use the throwable object in $context['exception'] (#207)
* Use the throwable object in $context['excpetion'] * add changelog * remove 'exception' from context * revert debug
This commit is contained in:
parent
abd0ddf13d
commit
7f02285753
1 changed files with 16 additions and 8 deletions
|
|
@ -63,6 +63,9 @@ function logger(): LoggerInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$exception = $context['exception'] ?? null;
|
||||
unset($context['exception']);
|
||||
|
||||
$logMessage = sprintf(
|
||||
"[%s] %s %s\n",
|
||||
strtoupper($level),
|
||||
|
|
@ -70,6 +73,10 @@ function logger(): LoggerInterface
|
|||
([] === $context || !$debug) ? '' : json_encode($context),
|
||||
);
|
||||
|
||||
if ($exception instanceof Throwable) {
|
||||
$logMessage .= sprintf('> %s', $exception->getMessage())."\n";
|
||||
}
|
||||
|
||||
if (($_SERVER['FILE_LOG'] ?? false) || !defined('STDERR')) {
|
||||
file_put_contents('dev.log', $logMessage, \FILE_APPEND);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue