diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index 8672ad821..f1c5b32cf 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -99,7 +99,7 @@ class CakeLog { * @return boolean success of configuration. * @throws Exception */ - static function config($key, $config) { + public static function config($key, $config) { if (empty($config['engine'])) { throw new Exception(__('Missing logger classname')); } @@ -222,47 +222,4 @@ class CakeLog { } return true; } - -/** - * An error_handler that will log errors to file using CakeLog::write(); - * You can control how verbose and what type of errors this error_handler will - * catch using `Configure::write('log', $value)`. See core.php for more information. - * - * - * @param integer $code Code of error - * @param string $description Error description - * @param string $file File on which error occurred - * @param integer $line Line that triggered the error - * @param array $context Context - * @return void - */ - public static function logError($code, $description, $file = null, $line = null, $context = null) { - switch ($code) { - case E_PARSE: - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - $error = 'Fatal Error'; - $level = LOG_ERROR; - break; - case E_WARNING: - case E_USER_WARNING: - case E_COMPILE_WARNING: - case E_RECOVERABLE_ERROR: - $error = 'Warning'; - $level = LOG_WARNING; - break; - case E_NOTICE: - case E_USER_NOTICE: - $error = 'Notice'; - $level = LOG_NOTICE; - break; - default: - return; - break; - } - $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; - CakeLog::write($level, $message); - } } diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 4fe3d100b..52c5c5abc 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -116,7 +116,9 @@ class CakeLogTest extends CakeTestCase { $result = CakeLog::configured(); $this->assertEqual($result, array('file')); - @unlink(LOGS . 'error.log'); + if (file_exists(LOGS . 'error.log')) { + @unlink(LOGS . 'error.log'); + } CakeLog::write(LOG_WARNING, 'Test warning'); $this->assertTrue(file_exists(LOGS . 'error.log')); @@ -164,25 +166,4 @@ class CakeLogTest extends CakeTestCase { unlink(LOGS . 'error.log'); } -/** - * Test logging with the error handler. - * - * @return void - */ - function testLoggingWithErrorHandling() { - @unlink(LOGS . 'debug.log'); - Configure::write('log', E_ALL & ~E_DEPRECATED); - Configure::write('debug', 0); - - set_error_handler(array('CakeLog', 'logError')); - $out .= ''; - - $result = file(LOGS . 'debug.log'); - $this->assertEqual(count($result), 1); - $this->assertPattern( - '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Notice: Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/', - $result[0] - ); - @unlink(LOGS . 'debug.log'); - } }