Class \Prado\Util\TDbLogRoute
TDbLogRoute stores log messages in a database table. To specify the database table, set \Prado\Util\setConnectionID to be the ID of a TDataSourceConfig module and \Prado\Util\setLogTableName. If they are not setting, an SQLite3 database named 'sqlite3.log' will be created and used under the runtime directory.
By default, the database table name is 'pradolog'. It has the following structure:
CREATE TABLE pradolog
(
log_id INTEGER NOT NULL PRIMARY KEY,
level INTEGER,
category VARCHAR(128),
prefix VARCHAR(128),
logtime VARCHAR(20),
message VARCHAR(255)
);
4.3.0 Notes: Add the prefix
to the log table:
ALTER TABLE pradolog ADD COLUMN prefix VARCHAR(128) AFTER category;
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Author: Brad Anderson <belisoful@icloud.com>
Since: 3.1.2
public
|
|
public
|
deleteDBLog([int|null $level = null ][, null|array<string|int, mixed>|string $categories = null ][, float|null $minTime = null ][, float|null $maxTime = null ]) : int
Deletes log items from the database that match the criteria.
|
public
|
|
public
|
|
public
|
|
public
|
getDBLogCount([int|null $level = null ][, null|array<string|int, mixed>|string $categories = null ][, float|null $minTime = null ][, float|null $maxTime = null ]) : string
Gets the number of logs in the database fitting the provided criteria.
|
public
|
getDBLogs([int|null $level = null ][, null|array<string|int, mixed>|string $categories = null ][, float|null $minTime = null ][, float|null $maxTime = null ][, string $order = '' ][, string $limit = '' ]) : TDbDataReader
Gets the number of logs in the database fitting the provided criteria.
|
public
|
|
public
|
|
public
|
init(TXmlElement $config) : mixed
Initializes this module.
This method is required by the IModule interface. It initializes the database for logging purpose. |
public
|
|
public
|
setConnectionID(string $value) : static
Sets the ID of a TDataSourceConfig module.
The datasource module will be used to establish the DB connection for this log route. |
public
|
setLogTableName(string $value) : static
Sets the name of the DB table to store log content.
Note, if \Prado\Util\setAutoCreateLogTable is false and you want to create the DB table manually by yourself, you need to make sure the DB table is of the following structure: (key CHAR(128) PRIMARY KEY, value BLOB, expire INT) |
public
|
|
public
static
|
|
protected
|
|
protected
|
|
protected
|
getLogWhere(int|null $level, null|array<string|int, mixed>|string $categories, float|null $minTime, float|null $maxTime, mixed &$values) : string
Computes the where SQL clause based upon level, categories, minimum time and maximum time.
|
protected
|
processLogs(array<string|int, mixed> $logs, bool $final, array<string|int, mixed> $meta) : mixed
Stores log messages into database.
|
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |