CLogRoute
CLogRoute is the base class for all log route classes.
A log route object retrieves log messages from a logger and sends it
somewhere, such as files, emails.
The messages being retrieved may be filtered first before being sent
to the destination. The filters include log level filter and log category filter.
To specify level filter, set
levels property,
which takes a string of comma-separated desired level names (e.g. 'Error, Debug').
To specify category filter, set
categories property,
which takes a string of comma-separated desired category names (e.g. 'System.Web, System.IO').
Level filter and category filter are combinational, i.e., only messages
satisfying both filter conditions will they be returned.
Public Properties
Hide inherited properties
| 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. |
CLogRoute |
| levels |
string |
list of levels separated by comma or space. |
CLogRoute |
| logs |
array |
the logs that are collected so far by this log route. |
CLogRoute |
Property Details
public string $categories;
list of categories separated by comma or space. Defaults to empty, meaning all categories.
public boolean $enabled;
whether to enable this log route. Defaults to true.
public mixed $filter;
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.
public string $levels;
list of levels separated by comma or space. Defaults to empty, meaning all levels.
public array $logs;
the logs that are collected so far by this log route.
Method Details
public void collectLogs( CLogger $logger, boolean $processLogs=false)
|
| $logger |
CLogger |
logger instance |
| $processLogs |
boolean |
whether to process the logs after they are collected from the logger |
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 |
Formats a log message given different fields.
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)); |
Processes log messages and sends them to specific destination.
Derived child classes must implement this method.