From 2e8bbd5eb1c46531147609aa266647f0c854b8f4 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Thu, 10 Sep 2009 12:32:21 -0300 Subject: [PATCH] Adding docblock for the new variable used for logging. Making the CakeLog::handleError logs the same output as in Debugger::handleError. --- app/config/core.php | 36 +++++++++++++++++++++ cake/console/templates/skel/config/core.php | 34 +++++++++++++++++-- cake/libs/cake_log.php | 7 ++-- cake/libs/debugger.php | 3 +- cake/tests/cases/libs/cake_log.test.php | 5 ++- 5 files changed, 76 insertions(+), 9 deletions(-) diff --git a/app/config/core.php b/app/config/core.php index 28ee3f5d6..22ca951c4 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -24,6 +24,7 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ + /** * CakePHP Debug Level: * @@ -39,10 +40,27 @@ * In development mode, you need to click the flash message to continue. */ Configure::write('debug', 2); + +/** + * CakePHP Log Level: + * + * In case of Production Mode CakePHP gives you the possibility to continue logging errors. + * + * The following parameters can be used: + * Boolean: Set true/false to activate/deactivate logging + * Configure::write('log', true); + * + * Integer: Use built-in PHP constants to set the error level (see error_reporting) + * Configure::write('log', E_ERROR | E_WARNING); + * Configure::write('log', E_ALL ^ E_NOTICE); + */ + Configure::write('log', true); + /** * Application wide charset encoding */ Configure::write('App.encoding', 'UTF-8'); + /** * To configure CakePHP *not* to use mod_rewrite and to * use CakePHP pretty URLs, remove these .htaccess @@ -55,6 +73,7 @@ * And uncomment the App.baseUrl below: */ //Configure::write('App.baseUrl', env('SCRIPT_NAME')); + /** * Uncomment the define below to use CakePHP admin routes. * @@ -71,6 +90,7 @@ * */ //Configure::write('Cache.disable', true); + /** * Enable cache checking. * @@ -81,11 +101,13 @@ * */ //Configure::write('Cache.check', true); + /** * Defines the default error type when using the log() function. Used for * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG. */ define('LOG_ERROR', 2); + /** * The preferred session handling method. Valid values: * @@ -101,6 +123,7 @@ * */ Configure::write('Session.save', 'php'); + /** * The model name to be used for the session model. * @@ -109,6 +132,7 @@ * The model name set here should *not* be used elsewhere in your application. */ //Configure::write('Session.model', 'Session'); + /** * The name of the table used to store CakePHP database sessions. * @@ -122,30 +146,36 @@ * [Note: Session.table is deprecated as of CakePHP 1.3] */ //Configure::write('Session.table', 'cake_sessions'); + /** * The DATABASE_CONFIG::$var to use for database session handling. * * 'Session.save' must be set to 'database' in order to utilize this constant. */ //Configure::write('Session.database', 'default'); + /** * The name of CakePHP's session cookie. */ Configure::write('Session.cookie', 'CAKEPHP'); + /** * Session time out time (in seconds). * Actual value depends on 'Security.level' setting. */ Configure::write('Session.timeout', '120'); + /** * If set to false, sessions are not automatically started. */ Configure::write('Session.start', true); + /** * When set to false, HTTP_USER_AGENT will not be checked * in the session */ Configure::write('Session.checkAgent', true); + /** * The level of CakePHP security. The session timeout time defined * in 'Session.timeout' is multiplied according to the settings here. @@ -159,10 +189,12 @@ * 'Security.level' is set to 'high'. */ Configure::write('Security.level', 'high'); + /** * A random string used in security hashing methods. */ Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); + /** * Compress CSS output by removing comments, whitespace, repeating tags, etc. * This requires a/var/cache directory to be writable by the web server for caching. @@ -171,6 +203,7 @@ * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css(). */ //Configure::write('Asset.filter.css', 'css.php'); + /** * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the * output, and setting the config below to the name of the script. @@ -178,17 +211,20 @@ * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link(). */ //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php'); + /** * The classname and database used in CakePHP's * access control lists. */ Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.database', 'default'); + /** * If you are on PHP 5.3 uncomment this line and correct your server timezone * to fix the date & time related errors. */ //date_default_timezone_set('UTC'); + /** * * Cache Engine Configuration diff --git a/cake/console/templates/skel/config/core.php b/cake/console/templates/skel/config/core.php index 8108c1999..22ca951c4 100644 --- a/cake/console/templates/skel/config/core.php +++ b/cake/console/templates/skel/config/core.php @@ -1,6 +1,5 @@ .php. * Set the value of 'Session.save' to to utilize it in CakePHP. * - * To use database sessions, execute the SQL file found at /app/config/sql/sessions.sql. + * To use database sessions, run the app/config/schema/sessions.php schema using + * the cake shell command: cake schema run create Sessions * */ Configure::write('Session.save', 'php'); +/** + * The model name to be used for the session model. + * + * 'Session.save' must be set to 'database' in order to utilize this constant. + * + * The model name set here should *not* be used elsewhere in your application. + */ + //Configure::write('Session.model', 'Session'); + /** * The name of the table used to store CakePHP database sessions. * * 'Session.save' must be set to 'database' in order to utilize this constant. * * The table name set here should *not* include any table prefix defined elsewhere. + * + * Please note that if you set a value for Session.model (above), any value set for + * Session.table will be ignored. + * + * [Note: Session.table is deprecated as of CakePHP 1.3] */ //Configure::write('Session.table', 'cake_sessions'); @@ -195,6 +224,7 @@ * to fix the date & time related errors. */ //date_default_timezone_set('UTC'); + /** * * Cache Engine Configuration diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index 3d7a29974..a0d556fbb 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -118,23 +118,26 @@ class CakeLog { 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 false; + return; break; } - $message = '(' . $code . ') ' . $description . ' in [' . $file . ', line ' . $line . ']'; + $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; CakeLog::write($level, $message); } } diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 8f39f4a3b..0fc535b2f 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -274,7 +274,6 @@ class Debugger extends Object { return; } - $level = LOG_DEBUG; switch ($code) { case E_PARSE: case E_ERROR: @@ -297,7 +296,7 @@ class Debugger extends Object { $level = LOG_NOTICE; break; default: - return false; + return; break; } diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 68319cdab..ebbe01444 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -60,14 +60,13 @@ class CakeLogTest extends CakeTestCase { Configure::write('log', E_ALL & ~E_DEPRECATED); Configure::write('debug', 0); - $logger = new CakeLog(); - Debugger::invoke($logger); + set_error_handler(array('CakeLog', 'handleError')); $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: \(8\) Undefined variable: out in \[.+ line \d{2}\]$/', + '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Debug: Notice \(8\): Undefined variable: out in \[.+ line \d{2}\]$/', $result[0] ); @unlink(LOGS . 'debug.log');