'warning', LOG_NOTICE => 'notice', LOG_INFO => 'info', LOG_DEBUG => 'debug', LOG_ERR => 'error', LOG_ERROR => 'error' ); if (is_int($type) && isset($levels[$type])) { $type = $levels[$type]; } if ($type == 'error' || $type == 'warning') { $filename = LOGS . 'error.log'; } elseif (in_array($type, $levels)) { $filename = LOGS . 'debug.log'; } else { $filename = LOGS . $type . '.log'; } $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n"; $log = new File($filename, true); if ($log->writable()) { return $log->append($output); } } /** * An error_handler that will log errors to file using CakeLog::write(); * * @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 **/ function handleError($code, $description, $file = null, $line = null, $context = null) { if ($code === 2048 || $code === 8192) { return; } 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); } } if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) { set_error_handler(array('CakeLog', 'handleError')); } ?>