Package | system.logging |
---|---|
Inheritance | abstract class CLogRoute » CComponent |
Subclasses | CDbLogRoute, CEmailLogRoute, CFileLogRoute, CWebLogRoute |
Since | 1.0 |
Version | $Id$ |
Source Code | framework/logging/CLogRoute.php |
Property | Type | Description | Defined By |
---|---|---|---|
categories | string | list of categories separated by comma or space. | CLogRoute |
enabled | boolean | whether to enable this log route. | CLogRoute |
filter | mixed | the additional filter (e.g. CLogFilter) that can be applied to the log messages. | CLogRoute |
levels | string | list of levels separated by comma or space. | CLogRoute |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | CComponent |
__get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
__isset() | Checks if a property value is null. | CComponent |
__set() | Sets value of a component property. | CComponent |
__unset() | Sets a component property to be null. | CComponent |
asa() | Returns the named behavior object. | CComponent |
attachBehavior() | Attaches a behavior to this component. | CComponent |
attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
attachEventHandler() | Attaches an event handler to an event. | CComponent |
canGetProperty() | Determines whether a property can be read. | CComponent |
canSetProperty() | Determines whether a property can be set. | CComponent |
collectLogs() | Retrieves filtered log messages from logger for further processing. | CLogRoute |
detachBehavior() | Detaches a behavior from the component. | CComponent |
detachBehaviors() | Detaches all behaviors from the component. | CComponent |
detachEventHandler() | Detaches an existing event handler. | CComponent |
disableBehavior() | Disables an attached behavior. | CComponent |
disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
enableBehavior() | Enables an attached behavior. | CComponent |
enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
hasEvent() | Determines whether an event is defined. | CComponent |
hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
hasProperty() | Determines whether a property is defined. | CComponent |
init() | Initializes the route. | CLogRoute |
raiseEvent() | Raises an event. | CComponent |
Method | Description | Defined By |
---|---|---|
formatLogMessage() | Formats a log message given different fields. | CLogRoute |
processLogs() | Processes log messages and sends them to specific destination. | CLogRoute |
list of categories separated by comma or space. Defaults to empty, meaning all categories.
whether to enable this log route. Defaults to true.
the additional filter (e.g. CLogFilter) that can be applied to the log messages. The value of this property will be passed to 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 CLogFilter or a child class of it. Defaults to null, meaning no filter will be used.
list of levels separated by comma or space. Defaults to empty, meaning all levels.
public void collectLogs(CLogger $logger)
| ||
$logger | CLogger | logger instance |
public function collectLogs($logger)
{
$logs=$logger->getLogs($this->levels,$this->categories);
if(!empty($logs))
{
if($this->filter!==null)
Yii::createComponent($this->filter)->filter($logs);
$this->processLogs($logs);
}
}
Retrieves filtered log messages from logger for further processing.
protected string formatLogMessage(string $message, integer $level, string $category, integer $time)
| ||
$message | string | message content |
$level | integer | message level |
$category | string | message category |
$time | integer | timestamp |
{return} | string | formatted message |
protected function formatLogMessage($message,$level,$category,$time)
{
return @date('Y/m/d H:i:s',$time)." [$level] [$category] $message\n";
}
Formats a log message given different fields.
public void init()
|
Initializes the route. This method is invoked after the route is created by the route manager.
abstract protected void processLogs(array $logs)
| ||
$logs | array | list of messages. Each array elements represents one message with the following structure: array( [0] => message (string) [1] => level (string) [2] => category (string) [3] => timestamp (float, obtained by microtime(true)); |
abstract protected function processLogs($logs);
Processes log messages and sends them to specific destination. Derived child classes must implement this method.
Signup or Login in order to comment.