From cf6d65f5678c6628767a2f3339b67fd1f67abaf4 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 10 Dec 2013 02:01:22 +0530 Subject: [PATCH] Renamed param $type of LogInterface::write() to $level. --- Cake/Log/Engine/BaseLog.php | 2 +- Cake/Log/Engine/ConsoleLog.php | 13 +++++------ Cake/Log/Engine/FileLog.php | 19 +++++++-------- Cake/Log/Engine/SyslogLog.php | 23 +++++++++---------- Cake/Log/Log.php | 4 ++-- Cake/Log/LogInterface.php | 11 +++++---- Cake/Test/TestApp/Log/Engine/TestAppLog.php | 2 +- .../TestPlugin/Log/Engine/TestPluginLog.php | 2 +- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Cake/Log/Engine/BaseLog.php b/Cake/Log/Engine/BaseLog.php index 478c0d92bd1..05cf45c9112 100644 --- a/Cake/Log/Engine/BaseLog.php +++ b/Cake/Log/Engine/BaseLog.php @@ -65,7 +65,7 @@ public function config($config = null) { } /** - * Get the levls this logger is interested in. + * Get the levels this logger is interested in. * * @return array */ diff --git a/Cake/Log/Engine/ConsoleLog.php b/Cake/Log/Engine/ConsoleLog.php index ec6f981209d..108891c3670 100644 --- a/Cake/Log/Engine/ConsoleLog.php +++ b/Cake/Log/Engine/ConsoleLog.php @@ -22,7 +22,6 @@ /** * Console logging. Writes logs to console output. - * */ class ConsoleLog extends BaseLog { @@ -38,7 +37,7 @@ class ConsoleLog extends BaseLog { * * Config * - * - `types` string or array, levels the engine is interested in + * - `levels` string or array, levels the engine is interested in * - `scopes` string or array, scopes the engine is interested in * - `stream` the path to save logs on. * - `outputAs` integer or ConsoleOutput::[RAW|PLAIN|COLOR] @@ -55,7 +54,7 @@ public function __construct($config = array()) { } $config = Hash::merge(array( 'stream' => 'php://stderr', - 'types' => null, + 'levels' => null, 'scopes' => array(), 'outputAs' => $outputAs, ), $this->_config); @@ -73,15 +72,15 @@ public function __construct($config = array()) { /** * Implements writing to console. * - * @param string $type The type of log you are making. + * @param string $level The severity level of log you are making. * @param string $message The message you want to log. * @param string|array $scope The scope(s) a log message is being created in. * See Cake\Log\Log::config() for more information on logging scopes. * @return boolean success of write. */ - public function write($type, $message, $scope = []) { - $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; - return $this->_output->write(sprintf('<%s>%s', $type, $output, $type), false); + public function write($level, $message, $scope = []) { + $output = date('Y-m-d H:i:s') . ' ' . ucfirst($level) . ': ' . $message . "\n"; + return $this->_output->write(sprintf('<%s>%s', $level, $output, $level), false); } } diff --git a/Cake/Log/Engine/FileLog.php b/Cake/Log/Engine/FileLog.php index 23b71e1909e..312e7737a57 100644 --- a/Cake/Log/Engine/FileLog.php +++ b/Cake/Log/Engine/FileLog.php @@ -118,15 +118,16 @@ public function config($config = array()) { /** * Implements writing to log files. * - * @param string $type The type of log you are making. + * @param string $level The severity level of the message being written. + * See Cake\Log\Log::$_levels for list of possible levels. * @param string $message The message you want to log. * @param string|array $scope The scope(s) a log message is being created in. * See Cake\Log\Log::config() for more information on logging scopes. * @return boolean success of write. */ - public function write($type, $message, $scope = []) { - $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; - $filename = $this->_getFilename($type); + public function write($level, $message, $scope = []) { + $output = date('Y-m-d H:i:s') . ' ' . ucfirst($level) . ': ' . $message . "\n"; + $filename = $this->_getFilename($level); if (!empty($this->_size)) { $this->_rotateFile($filename); } @@ -151,20 +152,20 @@ public function write($type, $message, $scope = []) { /** * Get filename - * @param string $type The type of log. + * @param string $level The level of log. * @return string File name */ - protected function _getFilename($type) { + protected function _getFilename($level) { $debugTypes = array('notice', 'info', 'debug'); if (!empty($this->_file)) { $filename = $this->_file; - } elseif ($type == 'error' || $type == 'warning') { + } elseif ($level == 'error' || $level == 'warning') { $filename = 'error.log'; - } elseif (in_array($type, $debugTypes)) { + } elseif (in_array($level, $debugTypes)) { $filename = 'debug.log'; } else { - $filename = $type . '.log'; + $filename = $level . '.log'; } return $filename; diff --git a/Cake/Log/Engine/SyslogLog.php b/Cake/Log/Engine/SyslogLog.php index ec151adcef3..6b56a9e9c43 100644 --- a/Cake/Log/Engine/SyslogLog.php +++ b/Cake/Log/Engine/SyslogLog.php @@ -24,9 +24,8 @@ class SyslogLog extends BaseLog { /** - * * By default messages are formatted as: - * type: message + * level: message * * To override the log format (e.g. to add your own info) define the format key when configuring * this logger @@ -40,12 +39,12 @@ class SyslogLog extends BaseLog { * ## Example: * * {{{ - * CakeLog::config('error', array( + * Log::config('error', ] * 'engine' => 'Syslog', - * 'types' => array('emergency', 'alert', 'critical', 'error'), + * 'levels' => ['emergency', 'alert', 'critical', 'error'], * 'format' => "%s: My-App - %s", * 'prefix' => 'Web Server 01' - * )); + * ]); * }}} * * @var array @@ -63,7 +62,7 @@ class SyslogLog extends BaseLog { * * @var array */ - protected $_priorityMap = array( + protected $_levelMap = array( 'emergency' => LOG_EMERG, 'alert' => LOG_ALERT, 'critical' => LOG_CRIT, @@ -95,16 +94,16 @@ public function __construct($config = array()) { /** * Writes a message to syslog * - * Map the $type back to a LOG_ constant value, split multi-line messages into multiple + * Map the $level back to a LOG_ constant value, split multi-line messages into multiple * log messages, pass all messages through the format defined in the configuration * - * @param string $type The type of log you are making. + * @param string $level The severity level of log you are making. * @param string $message The message you want to log. * @param string|array $scope The scope(s) a log message is being created in. * See Cake\Log\Log::config() for more information on logging scopes. * @return boolean success of write. */ - public function write($type, $message, $scope = []) { + public function write($level, $message, $scope = []) { if (!$this->_open) { $config = $this->_config; $this->_open($config['prefix'], $config['flag'], $config['facility']); @@ -112,13 +111,13 @@ public function write($type, $message, $scope = []) { } $priority = LOG_DEBUG; - if (isset($this->_priorityMap[$type])) { - $priority = $this->_priorityMap[$type]; + if (isset($this->_levelMap[$level])) { + $priority = $this->_levelMap[$level]; } $messages = explode("\n", $message); foreach ($messages as $message) { - $message = sprintf($this->_config['format'], $type, $message); + $message = sprintf($this->_config['format'], $level, $message); $this->_write($priority, $message); } diff --git a/Cake/Log/Log.php b/Cake/Log/Log.php index 9c9d8b362a8..d5d1ed172b8 100644 --- a/Cake/Log/Log.php +++ b/Cake/Log/Log.php @@ -319,8 +319,8 @@ public static function engine($name) { * then the logged message will be ignored and silently dropped. You can check if this has happened * by inspecting the return of write(). If false the message was not handled. * - * @param integer|string $level The level of the message being written. The value must be - * an integer or string matching a known level. + * @param integer|string $level The severity level of the message being written. + * The value must be an integer or string matching a known level. * @param string $message Message content to log * @param string|array $scope The scope(s) a log message is being created in. * See Cake\Log\Log::config() for more information on logging scopes. diff --git a/Cake/Log/LogInterface.php b/Cake/Log/LogInterface.php index 7b7f855518c..d568de1a1f7 100644 --- a/Cake/Log/LogInterface.php +++ b/Cake/Log/LogInterface.php @@ -19,17 +19,18 @@ /** * LogStreamInterface is the interface that should be implemented * by all classes that are going to be used as Log streams. - * */ interface LogInterface { /** * Write method to handle writes being made to the Logger * - * @param string $type - * @param string $message - * @param string|array $scope + * @param string $level The severity level of the message being written. + * See Cake\Log\Log::$_levels for list of possible levels. + * @param string $message Message content to log + * @param string|array $scope The scope(s) a log message is being created in. + * See Cake\Log\Log::config() for more information on logging scopes. * @return void */ - public function write($type, $message, $scope = []); + public function write($level, $message, $scope = []); } diff --git a/Cake/Test/TestApp/Log/Engine/TestAppLog.php b/Cake/Test/TestApp/Log/Engine/TestAppLog.php index 7ade82a8899..25ca0a36fd5 100644 --- a/Cake/Test/TestApp/Log/Engine/TestAppLog.php +++ b/Cake/Test/TestApp/Log/Engine/TestAppLog.php @@ -26,7 +26,7 @@ class TestAppLog extends BaseLog { public $passedScope = null; - public function write($type, $message, $scope = []) { + public function write($level, $message, $scope = []) { $this->passedScope = $scope; } diff --git a/Cake/Test/TestApp/Plugin/TestPlugin/Log/Engine/TestPluginLog.php b/Cake/Test/TestApp/Plugin/TestPlugin/Log/Engine/TestPluginLog.php index b55737a9571..a6719856035 100644 --- a/Cake/Test/TestApp/Plugin/TestPlugin/Log/Engine/TestPluginLog.php +++ b/Cake/Test/TestApp/Plugin/TestPlugin/Log/Engine/TestPluginLog.php @@ -22,7 +22,7 @@ */ class TestPluginLog implements LogInterface { - public function write($type, $message, $scope = []) { + public function write($level, $message, $scope = []) { } }