Adding stack traces to logged exceptions, as I forgot them last time around.

This commit is contained in:
mark_story 2010-12-11 12:47:16 -05:00
parent 9bfd170443
commit 504b4d495f
2 changed files with 7 additions and 1 deletions

View file

@ -110,7 +110,12 @@ class ErrorHandler {
if (!class_exists('CakeLog')) {
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') {
App::import('Lib', $config['renderer']);

View file

@ -220,6 +220,7 @@ class ErrorHandlerTest extends CakeTestCase {
$log = file(LOGS . 'error.log');
$this->assertPattern('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.');
$this->assertPattern('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.');
}
}