Class \Prado\Util\TLogRoute
TLogRoute 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 \Prado\Util\setLevels property, which takes a string of comma-separated desired level names (e.g. 'Error, Debug'). To specify category filter, set \Prado\Util\setCategories property, which takes a string of comma-separated desired category names (e.g. 'Prado\Web, Prado\IO').
The categories filter can use '!' or '~', e.g. '!Prado\Web\UI' or '~Prado\Web\UI', to exclude categories. Added 4.3.0.
Level filter and category filter are combinational, i.e., only messages satisfying both filter conditions will they be returned.
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Author: Brad Anderson <belisoful@icloud.com>
Since: 3.0
public
|
collectLogs([TLogger $logger = null ][, bool $final = false ]) : mixed
Retrieves log messages from logger to log route specific destination.
|
public
|
filterLogs(array<string|int, mixed> &$logs) : mixed
This filters the logs to calculate the delta and total times. It also calculates
the Profile times based upon the begin and end logged profile logs
|
public
|
formatLogMessage(array<string|int, mixed> $log) : string
Formats a log message given different fields.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
static
|
getLogColor(float $normalizedTime) : array<string|int, mixed>
Given $normalizedTime between 0 and 1 will produce an associated color.
Lowest values (~0) are black, then blue, green, yellow, orange, and red at 1. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
setEnabled(bool|callable $value) : static
This can be a boolean or a callable in the format:
```php
$route->setEnabled(
function(TLogRoute $route):bool {
return !Prado::getUser()?->getIsGuest()
}
);
```
|
public
|
|
public
|
setPrefixCallback(callable $value) : static
This is the application callback for changing the prefix in the format of:
```php
$route->setPrefixCallback(function(array $log, string $prefix) {
return $prefix . '[my data]';
});
```
|
public
|
|
protected
|
|
protected
|
|
protected
|
|
protected
abstract
|
processLogs(array<string|int, mixed> $logs, bool $final, array<string|int, mixed> $meta) : mixed
Processes log messages and sends them to specific destination.
Derived child classes must implement this method. |
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |