mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding stack traces to logged exceptions, as I forgot them last time around.
This commit is contained in:
parent
9bfd170443
commit
504b4d495f
2 changed files with 7 additions and 1 deletions
|
@ -110,7 +110,12 @@ class ErrorHandler {
|
||||||
if (!class_exists('CakeLog')) {
|
if (!class_exists('CakeLog')) {
|
||||||
require LIBS . 'cake_log.php';
|
require LIBS . 'cake_log.php';
|
||||||
}
|
}
|
||||||
CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage());
|
$message = sprintf("[%s] %s\n%s",
|
||||||
|
get_class($exception),
|
||||||
|
$exception->getMessage(),
|
||||||
|
$exception->getTraceAsString()
|
||||||
|
);
|
||||||
|
CakeLog::write(LOG_ERR, $message);
|
||||||
}
|
}
|
||||||
if ($config['renderer'] !== 'ExceptionRenderer') {
|
if ($config['renderer'] !== 'ExceptionRenderer') {
|
||||||
App::import('Lib', $config['renderer']);
|
App::import('Lib', $config['renderer']);
|
||||||
|
|
|
@ -220,6 +220,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
|
|
||||||
$log = file(LOGS . 'error.log');
|
$log = file(LOGS . 'error.log');
|
||||||
$this->assertPattern('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.');
|
$this->assertPattern('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.');
|
||||||
|
$this->assertPattern('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue