Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TDbLogRoute

TComponent
   |
   --TApplicationComponent
      |
      --TLogRoute
         |
         --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:

  1. CREATE TABLE pradolog
  2. (
  3. log_id INTEGER NOT NULL PRIMARY KEY,
  4. level INTEGER,
  5. category VARCHAR(128),
  6. logtime VARCHAR(20),
  7. message VARCHAR(255)
  8. );

Since: 3.1.2
Author: Qiang Xue <qiang.xue@gmail.com>

Method Summary
protected  TDbConnection
createDbConnection ( string 0)
Creates the DB connection.
protected  void
Creates the DB table for storing log messages.
boolean
string
TDbConnection
string
void
init ( TXmlElement $config)
Initializes this module.
protected  void
processLogs ( array $logs)
Stores log messages into database.
void
setAutoCreateLogTable ( boolean $value)
void
setConnectionID ( string $value)
Sets the ID of a TDataSourceConfig module.
void
setLogTableName ( string $value)
Sets the name of the DB table to store log content.
Methods Inherited From TLogRoute
TLogRoute::collectLogs(), TLogRoute::formatLogMessage(), TLogRoute::getCategories(), TLogRoute::getLevelName(), TLogRoute::getLevels(), TLogRoute::getLevelValue(), TLogRoute::init(), TLogRoute::setCategories(), TLogRoute::setLevels()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
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

protected TDbConnection createDbConnection (string 0 )

Creates the DB connection.

Input
string0the module ID for TDataSourceConfig
Output
TDbConnection the created DB connection
Exception
throwsTConfigurationException if module ID is invalid or empty

createDbTable

protected void createDbTable ()

Creates the DB table for storing log messages.

Output
Exception

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

public TDbConnection getDbConnection ()

Output
TDbConnection the DB connection instance
Exception

getLogTableName

public string getLogTableName ()

Output
string the name of the DB table to store log content. Defaults to 'pradolog'.
Exception

init

public void init (TXmlElement $config )

Initializes this module.

This method is required by the IModule interface. It initializes the database for logging purpose.

Input
TXmlElement$configconfiguration for this module, can be null
Output
Exception
throwsTConfigurationException if the DB table does not exist.

processLogs

protected void processLogs (array $logs )

Stores log messages into database.

Input
array$logslist of log messages
Output
Exception

setAutoCreateLogTable

public void setAutoCreateLogTable (boolean $value )

Input
boolean$valuewhether 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.

Input
string$valueID of the TDataSourceConfig module
Output
Exception

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$valuethe name of the DB table to store log content
Output
Exception