CLogFilter
| Package |
system.logging |
| Inheritance |
class CLogFilter »
CComponent |
| Since |
1.0.6 |
| Version |
$Id: CLogFilter.php 1678 2010-01-07 21:02:00Z qiang.xue $ |
CLogFilter preprocesses the logged messages before they are handled by a log route.
CLogFilter is meant to be used by a log route to preprocess the logged messages
before they are handled by the route. The default implementation of CLogFilter
prepends additional context information to the logged messages. In particular,
by setting
logVars, predefined PHP variables such as
$_SERVER, $_POST, etc. can be saved as a log message, which may help identify/debug
issues encountered.
Public Properties
Hide inherited properties
| Property | Type | Description | Defined By |
| logUser |
boolean |
whether to log the current user name and ID. |
CLogFilter |
| logVars |
array |
list of the PHP predefined variables that should be logged. |
CLogFilter |
| prefixSession |
boolean |
whether to prefix each log message with the current user session ID. |
CLogFilter |
| prefixUser |
boolean |
whether to prefix each log message with the current user
name and ID. |
CLogFilter |
Property Details
Generates the context information to be logged.
The default implementation will dump user information, system variables, etc.
public boolean $logUser;
whether to log the current user name and ID. Defaults to true.
This property is effective only when showContext is true.
public array $logVars;
list of the PHP predefined variables that should be logged.
Note that a variable must be accessible via $GLOBALS. Otherwise it won't be logged.
public boolean $prefixSession;
whether to prefix each log message with the current user session ID.
Defaults to false.
public boolean $prefixUser;
whether to prefix each log message with the current user
name and ID. Defaults to false.
Method Details
|
public void filter(array $logs)
|
| $logs |
array |
the log messages |
Filters the given log messages.
This is the main method of CLogFilter. It processes the log messages
by adding context information, etc.
|
protected void format($logs)
|
| $logs |
|
|
Formats the log messages.
The default implementation will prefix each message with session ID
if prefixSession is set true. It may also prefix each message
with the current user's name and ID if prefixUser is true.
|
protected string getContext()
|
| {return} |
string |
the context information. If an empty string, it means no context information. |
Generates the context information to be logged.
The default implementation will dump user information, system variables, etc.