Class \Prado\Util\TLogger
TLogger records log messages in memory and implements the methods to retrieve the messages with filter conditions, including log levels, log categories, and by control.
Filtering categories and controls can use a '!' or '~' prefix and the element will be excluded rather than included. Using a trailing '*' will include elements starting with the specified text.
The log message, log level, log category (class), microtime Time stamp memory used, control ID, traces, and process ID.
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Author: Brad Anderson <belisoful@icloud.com>
Since: 3.0
public
|
|
public
|
deleteLogs([null|int $levels = null ][, null|array<string|int, mixed>|string $categories = null ][, null|array<string|int, mixed>|string $controls = null ][, null|float|int $timestamp = null ][, int|null $pid = null ]) : array<string|int, mixed>
Deletes log messages from the queue.
Messages may be filtered by log levels and/or categories and/or control client ids and/or timestamp. A level filter is specified by an integer, whose bits indicate the levels interested. For example, (TLogger::INFO | TLogger::WARNING) specifies INFO and WARNING levels. A category filter is specified by an array of categories to filter. A message whose category name starts with any filtering category will be deleted. For example, a category filter array('Prado\Web','Prado\IO') will delete messages under categories such as 'Prado\Web', 'Prado\IO', 'Prado\Web\UI', 'Prado\Web\UI\WebControls', etc. A control client id filter is specified by an array of control client id A message whose control client id starts with any filtering naming panels will be deleted. For example, a category filter array('ctl0_body_header', 'ctl0_body_content_sidebar') will delete messages under categories such as 'ctl0_body_header', 'ctl0_body_content_sidebar', 'ctl0_body_header_title', 'ctl0_body_content_sidebar_savebutton', etc. A timestamp filter is specified as an interger or float number. A message whose registered timestamp is less or equal the filter value will be returned. Level filter, category filter, control filter and timestamp filter are combinational, i.e., only messages satisfying all filter conditions will they be returned. |
public
|
|
public
|
|
public
|
getLogCount([bool|null $selector = null ]) : int
This returns the number of logs being held. When the $selector the following
is returned:
- null is the ~ number of logs a route will receive
- 0 is the ~ number of logs to be collected before removing static::LOGGGED logs
- true is the number of logs without profile begin
- false is the number of profile begin logs
When a PROFILE_BEGIN is flushed without a paired PROFILE_END, then it is logged and flagged as static::LOGGED. These log items will be resent until and with a paired PROFILE_END. The PROFILE_BEGIN are relogged to computing timing but are removed before being processed by the log route. |
public
|
|
public
|
getLogs([int|null $levels = null ][, null|array<string|int, mixed>|string $categories = null ][, null|array<string|int, mixed>|string $controls = null ][, null|float|int $timestamp = null ][, int|null $pid = null ]) : array<string|int, mixed>
Retrieves log messages.
Messages may be filtered by log levels and/or categories and/or control client ids and/or timestamp. A level filter is specified by an integer, whose bits indicate the levels interested. For example, (TLogger::INFO | TLogger::WARNING) specifies INFO and WARNING levels. A category filter is specified by an array of categories to filter. A message whose category name starts with any filtering category will be returned. For example, a category filter array('Prado\Web','Prado\IO') will return messages under categories such as 'Prado\Web', 'Prado\IO', 'Prado\Web\UI', 'Prado\Web\UI\WebControls', etc. A control client id filter is specified by an array of control client id A message whose control client id starts with any filtering naming panels will be returned. For example, a category filter array('ctl0_body_header', 'ctl0_body_content_sidebar') will return messages under categories such as 'ctl0_body_header', 'ctl0_body_content_sidebar', 'ctl0_body_header_title', 'ctl0_body_content_sidebar_savebutton', etc. A timestamp filter is specified as an interger or float number. A message whose registered timestamp is less or equal the filter value will be returned. Level filter, category filter, control filter and timestamp filter are combinational, i.e., only messages satisfying all filter conditions will they be returned. |
public
|
|
public
|
|
public
|
mergeLogs(array<string|int, mixed> $logs) : mixed
This merges a set of logs with the current running logs.
|
public
|
onCollectLogs([bool $final = false ]) : mixed
This event collects any logs from other aspects of the application that may
not be able to directly log to the TLogger.
|
public
|
onFlushLogs([mixed $sender = null ][, mixed $final = null ]) : mixed
This is an Event and an event handler. When {@see Application::onEndRequest()}
is raised and as a `register_shutdown_function` function, this is called.
On calling, this raises the event |
public
|
|
public
|
|
protected
|
|
protected
|
checkLogsSize([bool $flush = true ]) : mixed
If we allow a flush (not a bulk logging), and the log count is equal to or more
than the FlushCount then we flush the logs.
|
protected
|
checkProfileLogsSize([bool $flush = true ]) : mixed
When the ProfileLog Count is equal or more than the FlushCount, then the Retained
profile logs are deleted and a WARNING is logged.
|
protected
|
|
private
|
filterByCategories(array<string|int, mixed> $log) : bool
Filter function used by {@see static::getLogs()}.
|
private
|
filterByControl(array<string|int, mixed> $log) : bool
Filter function used by {@see static::getLogs()}
|
private
|
filterByLevels(array<string|int, mixed> $log) : bool
Filter function used by {@see static::getLogs()}
|
private
|
|
private
|
filterByTimeStamp(array<string|int, mixed> $log) : bool
Filter function used by {@see static::getLogs()}
|
private
|
public
mixed
|
ALERT
|
0x20
|
public
mixed
|
DEBUG
Log levels.
|
0x1
|
public
mixed
|
ERROR
|
0x10
|
public
mixed
|
FATAL
|
0x40
|
public
mixed
|
INFO
|
0x2
|
public
mixed
|
LOG_CATEGORY
|
2
|
public
mixed
|
LOG_CONTROL
|
5
|
public
mixed
|
LOG_LEVEL
|
1
|
public
mixed
|
LOG_MEMORY
|
4
|
public
mixed
|
LOG_MESSAGE
Log Information Index.
|
0
|
public
mixed
|
LOG_PID
|
7
|
public
mixed
|
LOG_TIME
|
3
|
public
mixed
|
LOG_TRACES
|
6
|
public
mixed
|
LOGGED
|
0x8000
|
public
mixed
|
NOTICE
|
0x4
|
public
mixed
|
PROFILE
|
0x100
|
public
mixed
|
PROFILE_BEGIN
|
0x300
|
public
mixed
|
PROFILE_BEGIN_SELECT
These are for selecting just the PROFILE_BEGIN and PROFILE_END logs without
the PROFILE bit.
|
0x200
|
public
mixed
|
PROFILE_END
|
0x500
|
public
mixed
|
PROFILE_END_SELECT
|
0x400
|
public
mixed
|
WARNING
|
0x8
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |