Class TDbLogRoute
TDbLogRoute class
TDbLogRoute stores log messages in a database table. To specify the database table, set ConnectionID to be the ID of a TDataSourceConfig module and 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)
- );
Method Summary |
protected
TDbConnection
|
Creates the DB connection.
|
protected
void
|
Creates the DB table for storing log messages.
|
boolean
|
|
string
|
|
TDbConnection
|
|
string
|
|
void
|
Initializes this module.
|
protected
void
|
Stores log messages into database.
|
void
|
|
void
|
Sets the ID of a TDataSourceConfig module.
|
void
|
Sets the name of the DB table to store log content.
|
Methods Inherited From TComponent |
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
|
Method Details |
createDbConnection
Creates the DB connection.
Input |
string | 0 | the module ID for TDataSourceConfig |
Output |
TDbConnection
| the created DB connection |
Exception |
throws | TConfigurationException if module ID is invalid or empty |
|
createDbTable
protected void createDbTable |
() |
Creates the DB table for storing log messages.
|
getAutoCreateLogTable
public boolean getAutoCreateLogTable |
() |
Output |
boolean
| whether the log DB table should be automatically created if not exists. Defaults to true. |
Exception |
|
getConnectionID
public string getConnectionID |
() |
Output |
string
| the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set. |
Exception |
|
getDbConnection
|
getLogTableName
public string getLogTableName |
() |
Output |
string
| the name of the DB table to store log content. Defaults to 'pradolog'. |
Exception |
|
init
Initializes this module.
This method is required by the IModule interface. It initializes the database for logging purpose.
Input |
TXmlElement | $config | configuration for this module, can be null |
Output |
Exception |
throws | TConfigurationException if the DB table does not exist. |
|
processLogs
protected void processLogs |
(array $logs ) |
Stores log messages into database.
Input |
array | $logs | list of log messages |
Output |
Exception |
|
setAutoCreateLogTable
public void setAutoCreateLogTable |
(boolean $value ) |
Input |
boolean | $value | whether the log DB table should be automatically created if not exists. |
Output |
Exception |
|
setConnectionID
public void setConnectionID |
(string $value ) |
Sets the ID of a TDataSourceConfig module.
The datasource module will be used to establish the DB connection for this log route.
|
setLogTableName
public void setLogTableName |
(string $value ) |
Sets the name of the DB table to store log content.
Note, if 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)
Input |
string | $value | the name of the DB table to store log content |
Output |
Exception |
|
|