Skip to content
Permalink
Browse files

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

…around.
  • Loading branch information...
markstory committed Dec 11, 2010
1 parent 9bfd170 commit 504b4d495f72cd34f581813029775c2488350ddf
Showing with 7 additions and 1 deletion.
  1. +6 −1 cake/libs/error/error_handler.php
  2. +1 −0 cake/tests/cases/libs/error/error_handler.test.php
@@ -110,7 +110,12 @@ public static function handleException(Exception $exception) {
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']);
@@ -220,6 +220,7 @@ function testHandleExceptionLog() {
$log = file(LOGS . 'error.log');
$this->assertPattern('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.');
$this->assertPattern('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.');
}
}

0 comments on commit 504b4d4

Please sign in to comment.
You can’t perform that action at this time.