Adding docblock for the new variable used for logging. Making the CakeLog::handleError logs the same output as in Debugger::handleError.

This commit is contained in:
renan.saddam 2009-09-10 12:32:21 -03:00
parent 4766f62029
commit 2e8bbd5eb1
5 changed files with 76 additions and 9 deletions

View file

@ -24,6 +24,7 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* CakePHP Debug Level: * CakePHP Debug Level:
* *
@ -39,10 +40,27 @@
* In development mode, you need to click the flash message to continue. * In development mode, you need to click the flash message to continue.
*/ */
Configure::write('debug', 2); 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 * Application wide charset encoding
*/ */
Configure::write('App.encoding', 'UTF-8'); Configure::write('App.encoding', 'UTF-8');
/** /**
* To configure CakePHP *not* to use mod_rewrite and to * To configure CakePHP *not* to use mod_rewrite and to
* use CakePHP pretty URLs, remove these .htaccess * use CakePHP pretty URLs, remove these .htaccess
@ -55,6 +73,7 @@
* And uncomment the App.baseUrl below: * And uncomment the App.baseUrl below:
*/ */
//Configure::write('App.baseUrl', env('SCRIPT_NAME')); //Configure::write('App.baseUrl', env('SCRIPT_NAME'));
/** /**
* Uncomment the define below to use CakePHP admin routes. * Uncomment the define below to use CakePHP admin routes.
* *
@ -71,6 +90,7 @@
* *
*/ */
//Configure::write('Cache.disable', true); //Configure::write('Cache.disable', true);
/** /**
* Enable cache checking. * Enable cache checking.
* *
@ -81,11 +101,13 @@
* *
*/ */
//Configure::write('Cache.check', true); //Configure::write('Cache.check', true);
/** /**
* Defines the default error type when using the log() function. Used for * Defines the default error type when using the log() function. Used for
* differentiating error logging and debugging. Currently PHP supports LOG_DEBUG. * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG.
*/ */
define('LOG_ERROR', 2); define('LOG_ERROR', 2);
/** /**
* The preferred session handling method. Valid values: * The preferred session handling method. Valid values:
* *
@ -101,6 +123,7 @@
* *
*/ */
Configure::write('Session.save', 'php'); Configure::write('Session.save', 'php');
/** /**
* The model name to be used for the session model. * 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. * The model name set here should *not* be used elsewhere in your application.
*/ */
//Configure::write('Session.model', 'Session'); //Configure::write('Session.model', 'Session');
/** /**
* The name of the table used to store CakePHP database sessions. * 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] * [Note: Session.table is deprecated as of CakePHP 1.3]
*/ */
//Configure::write('Session.table', 'cake_sessions'); //Configure::write('Session.table', 'cake_sessions');
/** /**
* The DATABASE_CONFIG::$var to use for database session handling. * The DATABASE_CONFIG::$var to use for database session handling.
* *
* 'Session.save' must be set to 'database' in order to utilize this constant. * 'Session.save' must be set to 'database' in order to utilize this constant.
*/ */
//Configure::write('Session.database', 'default'); //Configure::write('Session.database', 'default');
/** /**
* The name of CakePHP's session cookie. * The name of CakePHP's session cookie.
*/ */
Configure::write('Session.cookie', 'CAKEPHP'); Configure::write('Session.cookie', 'CAKEPHP');
/** /**
* Session time out time (in seconds). * Session time out time (in seconds).
* Actual value depends on 'Security.level' setting. * Actual value depends on 'Security.level' setting.
*/ */
Configure::write('Session.timeout', '120'); Configure::write('Session.timeout', '120');
/** /**
* If set to false, sessions are not automatically started. * If set to false, sessions are not automatically started.
*/ */
Configure::write('Session.start', true); Configure::write('Session.start', true);
/** /**
* When set to false, HTTP_USER_AGENT will not be checked * When set to false, HTTP_USER_AGENT will not be checked
* in the session * in the session
*/ */
Configure::write('Session.checkAgent', true); Configure::write('Session.checkAgent', true);
/** /**
* The level of CakePHP security. The session timeout time defined * The level of CakePHP security. The session timeout time defined
* in 'Session.timeout' is multiplied according to the settings here. * in 'Session.timeout' is multiplied according to the settings here.
@ -159,10 +189,12 @@
* 'Security.level' is set to 'high'. * 'Security.level' is set to 'high'.
*/ */
Configure::write('Security.level', 'high'); Configure::write('Security.level', 'high');
/** /**
* A random string used in security hashing methods. * A random string used in security hashing methods.
*/ */
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
/** /**
* Compress CSS output by removing comments, whitespace, repeating tags, etc. * 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. * 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(). * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css().
*/ */
//Configure::write('Asset.filter.css', 'css.php'); //Configure::write('Asset.filter.css', 'css.php');
/** /**
* Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the * 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. * 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(). * 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'); //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');
/** /**
* The classname and database used in CakePHP's * The classname and database used in CakePHP's
* access control lists. * access control lists.
*/ */
Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default'); Configure::write('Acl.database', 'default');
/** /**
* If you are on PHP 5.3 uncomment this line and correct your server timezone * If you are on PHP 5.3 uncomment this line and correct your server timezone
* to fix the date & time related errors. * to fix the date & time related errors.
*/ */
//date_default_timezone_set('UTC'); //date_default_timezone_set('UTC');
/** /**
* *
* Cache Engine Configuration * Cache Engine Configuration

View file

@ -1,6 +1,5 @@
<?php <?php
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* This is core configuration file. * This is core configuration file.
* *
@ -42,6 +41,21 @@
*/ */
Configure::write('debug', 2); 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 * Application wide charset encoding
*/ */
@ -104,17 +118,32 @@
* To define a custom session handler, save it at /app/config/<name>.php. * To define a custom session handler, save it at /app/config/<name>.php.
* Set the value of 'Session.save' to <name> to utilize it in CakePHP. * Set the value of 'Session.save' to <name> 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'); 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. * The name of the table used to store CakePHP database sessions.
* *
* 'Session.save' must be set to 'database' in order to utilize this constant. * '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. * 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'); //Configure::write('Session.table', 'cake_sessions');
@ -195,6 +224,7 @@
* to fix the date & time related errors. * to fix the date & time related errors.
*/ */
//date_default_timezone_set('UTC'); //date_default_timezone_set('UTC');
/** /**
* *
* Cache Engine Configuration * Cache Engine Configuration

View file

@ -118,23 +118,26 @@ class CakeLog {
case E_CORE_ERROR: case E_CORE_ERROR:
case E_COMPILE_ERROR: case E_COMPILE_ERROR:
case E_USER_ERROR: case E_USER_ERROR:
$error = 'Fatal Error';
$level = LOG_ERROR; $level = LOG_ERROR;
break; break;
case E_WARNING: case E_WARNING:
case E_USER_WARNING: case E_USER_WARNING:
case E_COMPILE_WARNING: case E_COMPILE_WARNING:
case E_RECOVERABLE_ERROR: case E_RECOVERABLE_ERROR:
$error = 'Warning';
$level = LOG_WARNING; $level = LOG_WARNING;
break; break;
case E_NOTICE: case E_NOTICE:
case E_USER_NOTICE: case E_USER_NOTICE:
$error = 'Notice';
$level = LOG_NOTICE; $level = LOG_NOTICE;
break; break;
default: default:
return false; return;
break; break;
} }
$message = '(' . $code . ') ' . $description . ' in [' . $file . ', line ' . $line . ']'; $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
CakeLog::write($level, $message); CakeLog::write($level, $message);
} }
} }

View file

@ -274,7 +274,6 @@ class Debugger extends Object {
return; return;
} }
$level = LOG_DEBUG;
switch ($code) { switch ($code) {
case E_PARSE: case E_PARSE:
case E_ERROR: case E_ERROR:
@ -297,7 +296,7 @@ class Debugger extends Object {
$level = LOG_NOTICE; $level = LOG_NOTICE;
break; break;
default: default:
return false; return;
break; break;
} }

View file

@ -60,14 +60,13 @@ class CakeLogTest extends CakeTestCase {
Configure::write('log', E_ALL & ~E_DEPRECATED); Configure::write('log', E_ALL & ~E_DEPRECATED);
Configure::write('debug', 0); Configure::write('debug', 0);
$logger = new CakeLog(); set_error_handler(array('CakeLog', 'handleError'));
Debugger::invoke($logger);
$out .= ''; $out .= '';
$result = file(LOGS . 'debug.log'); $result = file(LOGS . 'debug.log');
$this->assertEqual(count($result), 1); $this->assertEqual(count($result), 1);
$this->assertPattern( $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] $result[0]
); );
@unlink(LOGS . 'debug.log'); @unlink(LOGS . 'debug.log');