Skip to content

Commit

Permalink
added ILogFilter interface
Browse files Browse the repository at this point in the history
according to discussion in issue yiisoft#684
  • Loading branch information
cebe committed Jun 29, 2012
1 parent eea37e5 commit 59ac778
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ Version 1.1.11 work in progress
- Enh: Added CErrorHandler::getHttpHeader() to send correct HTTP error codes (pgaultier)
- Enh: CGridView, only rows in tbody should have hover effect (mdomba)
- Enh: CHttpCookie now implements __toString (suralc)
- Enh: added possibility to set the container for CHtml::radioButtonList and CHtml::checkBoxList() (pgaultier)
- Enh: added zii romanian(ro) translation; edited core messages to include proper romanian characters with diacritic marks (tudorilisoi)
- Enh: Added possibility to set the container for CHtml::radioButtonList and CHtml::checkBoxList() (pgaultier)
- Enh: Added zii romanian(ro) translation; edited core messages to include proper romanian characters with diacritic marks (tudorilisoi)
- Enh: Added ILogFilter interface as an alternative to using CLogFilter as base class for implementing log filters (cebe)
- Chg #440: Upgraded JQuery UI to 1.8.20 (samdark)
- Chg #497: Added log component and preloaded it in default console application config in order to properly log errors (samdark)
- Chg: Upgraded jQuery to 1.7.2 (samdark)
Expand Down
31 changes: 30 additions & 1 deletion framework/base/interfaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,33 @@ public function getSort();
* @return CPagination the pagination object. If this is false, it means the pagination is disabled.
*/
public function getPagination();
}
}


/**
* ILogFilter is the interface that must be implemented by log filters.
*
* A log filter preprocesses the logged messages before they are handled by a log route.
* Classes that implement ILogFilter will be attached to {@link CLogRoute::$filter}.
*
* @version $Id$
* @package system.logging
* @since 1.1.11
*/
interface ILogFilter
{
/**
* This method should be implemented to perform actual filtering of log messages
* by working on the array given as the first parameter.
* Implementation might reformat, remove or add information to logged messages.
* @param array $logs list of messages. Each array element represents one message
* with the following structure:
* array(
* [0] => message (string)
* [1] => level (string)
* [2] => category (string)
* [3] => timestamp (float, obtained by microtime(true));
*/
public function filter(&$logs);
}

2 changes: 1 addition & 1 deletion framework/logging/CLogFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @version $Id$
* @package system.logging
*/
class CLogFilter extends CComponent
class CLogFilter extends CComponent implements ILogFilter
{
/**
* @var boolean whether to prefix each log message with the current user session ID.
Expand Down
4 changes: 2 additions & 2 deletions framework/logging/CLogRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ abstract class CLogRoute extends CComponent
* The value of this property will be passed to {@link Yii::createComponent} to create
* a log filter object. As a result, this can be either a string representing the
* filter class name or an array representing the filter configuration.
* In general, the log filter class should be {@link CLogFilter} or a child class of it.
* In general, the log filter class should implement {@link ILogFilter} interface.
* Defaults to null, meaning no filter will be used.
*/
public $filter;
Expand Down Expand Up @@ -102,7 +102,7 @@ public function collectLogs($logger, $processLogs=false)
/**
* Processes log messages and sends them to specific destination.
* Derived child classes must implement this method.
* @param array $logs list of messages. Each array elements represents one message
* @param array $logs list of messages. Each array element represents one message
* with the following structure:
* array(
* [0] => message (string)
Expand Down
4 changes: 2 additions & 2 deletions framework/logging/CLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* CLogger implements the methods to retrieve the messages with
* various filter conditions, including log levels and log categories.
*
* @property array $logs List of messages. Each array elements represents one message
* @property array $logs List of messages. Each array element represents one message
* with the following structure:
* array(
* [0] => message (string)
Expand Down Expand Up @@ -118,7 +118,7 @@ public function log($message,$level='info',$category='application')
*
* @param string $levels level filter
* @param string $categories category filter
* @return array list of messages. Each array elements represents one message
* @return array list of messages. Each array element represents one message
* with the following structure:
* array(
* [0] => message (string)
Expand Down

0 comments on commit 59ac778

Please sign in to comment.