PHP Class Prado\Util\TDbLogRoute

TDbLogRoute stores log messages in a database table. To specify the database table, set {@link setConnectionID ConnectionID} to be the ID of a {@link TDataSourceConfig} module and {@link setLogTableName LogTableName}. 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), logtime VARCHAR(20), message VARCHAR(255) );
Since: 3.1.2
Author: Qiang Xue ([email protected])
Inheritance: extends TLogRoute
Mostra file Open project: pradosoft/prado

Public Methods

Method Description
__destruct ( ) Destructor.
getAutoCreateLogTable ( ) : boolean
getConnectionID ( ) : string
getDbConnection ( ) : TDbConnection
getLogTableName ( ) : string
init ( $config ) Initializes this module.
setAutoCreateLogTable ( $value )
setConnectionID ( $value ) Sets the ID of a TDataSourceConfig module.
setLogTableName ( $value ) Sets the name of the DB table to store log content.

Protected Methods

Method Description
createDbConnection ( ) : TDbConnection Creates the DB connection.
createDbTable ( ) Creates the DB table for storing log messages.
processLogs ( $logs ) Stores log messages into database.

Method Details

__destruct() public method

Disconnect the db connection.
public __destruct ( )

createDbConnection() protected method

Creates the DB connection.
protected createDbConnection ( ) : TDbConnection
return Prado\Data\TDbConnection the created DB connection

createDbTable() protected method

Creates the DB table for storing log messages.
protected createDbTable ( )

getAutoCreateLogTable() public method

See also: setAutoCreateLogTable
public getAutoCreateLogTable ( ) : boolean
return boolean whether the log DB table should be automatically created if not exists. Defaults to true.

getConnectionID() public method

public getConnectionID ( ) : string
return string the ID of a {@link TDataSourceConfig} module. Defaults to empty string, meaning not set.

getDbConnection() public method

public getDbConnection ( ) : TDbConnection
return Prado\Data\TDbConnection the DB connection instance

getLogTableName() public method

See also: setAutoCreateLogTable
public getLogTableName ( ) : string
return string the name of the DB table to store log content. Defaults to 'pradolog'.

init() public method

This method is required by the IModule interface. It initializes the database for logging purpose.
public init ( $config )

processLogs() protected method

Stores log messages into database.
protected processLogs ( $logs )

setAutoCreateLogTable() public method

See also: setLogTableName
public setAutoCreateLogTable ( $value )

setConnectionID() public method

The datasource module will be used to establish the DB connection for this log route.
public setConnectionID ( $value )

setLogTableName() public method

Note, if {@link setAutoCreateLogTable AutoCreateLogTable} 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)
See also: setAutoCreateLogTable
public setLogTableName ( $value )