Improve formatting of backtrace in error log

This commit is contained in:
Dale Davies
2023-04-12 21:30:24 +01:00
parent 345aced953
commit 1779fa1327

View File

@@ -39,15 +39,16 @@ class ErrorLogger implements \Tracy\ILogger {
if (empty($callers)) {
return '';
}
$count = 1;
$from = '';
foreach ($callers as $caller) {
if (!isset($caller['line'])) {
$caller['line'] = '?'; // probably call_user_func()
$caller['line'] = '?';
}
if (!isset($caller['file'])) {
$caller['file'] = 'unknownfile'; // probably call_user_func()
$caller['file'] = 'unknownfile';
}
$from .= '* ';
$from .= '- #'.$count.' ';
$from .= 'line ' . $caller['line'] . ' of ' . str_replace(dirname(__DIR__), '', $caller['file']);
if (isset($caller['function'])) {
$from .= ': call to ';
@@ -59,6 +60,7 @@ class ErrorLogger implements \Tracy\ILogger {
$from .= ': '.$caller['exception'].' thrown';
}
$from .= PHP_EOL;
$count ++;
}
$from .= '';
return $from;