## Class TDbLogRoute

Description

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)
       );

- since: 3.1.2
- version: $Id: TLogRouter.php 2694 2009-07-20 11:53:36Z carlgmathisen $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Util/TLogRouter.php (line 788)

    TComponent
       |
       --TApplicationComponent
          |
          --TLogRoute
             |
             --TDbLogRoute

Method Summary
void __destruct ()
TDbConnection createDbConnection (string 0)
void createDbTable ()
boolean getAutoCreateLogTable ()
string getConnectionID ()
TDbConnection getDbConnection ()
string getLogTableName ()
void init (TXmlElement $config)
void processLogs (array $logs)
void setAutoCreateLogTable (boolean $value)
void setConnectionID (string $value)
void setLogTableName (string $value)
Variables

#### Inherited Variables

Inherited from TLogRoute

> TLogRoute::$_levelNames
> TLogRoute::$_levelValues

Methods
Destructor __destruct (line 811)

Destructor.

Disconnect the db connection.

- access: public

void __destruct ()
createDbConnection (line 886)

Creates the DB connection.

- return: the created DB connection
- access: protected
- throws: TConfigurationException if module ID is invalid or empty

TDbConnection createDbConnection (string 0)

- string 0: the module ID for TDataSourceConfig

createDbTable (line 868)

Creates the DB table for storing log messages.

- access: protected
- todo: create sequence for PostgreSQL

void createDbTable ()
getAutoCreateLogTable (line 961)

- return: whether the log DB table should be automatically created if not exists. Defaults to true.
- access: public
- see: TDbLogRoute::setAutoCreateLogTable()

boolean getAutoCreateLogTable ()
getConnectionID (line 919)

- return: the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
- access: public

string getConnectionID ()
getDbConnection (line 909)

- return: the DB connection instance
- access: public

TDbConnection getDbConnection ()
getLogTableName (line 938)

- return: the name of the DB table to store log content. Defaults to 'pradolog'.
- access: public
- see: TDbLogRoute::setAutoCreateLogTable()

string getLogTableName ()
init (line 824)

Initializes this module.

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

- access: public
- throws: TConfigurationException if the DB table does not exist.

void init (TXmlElement $config)

- TXmlElement $config: configuration for this module, can be null

Redefinition of:

TLogRoute::init()
  Initializes the route.

processLogs (line 850)

Stores log messages into database.

- access: protected

void processLogs (array $logs)

- array $logs: list of log messages

Redefinition of:

TLogRoute::processLogs()
  Processes log messages and sends them to specific destination.

setAutoCreateLogTable (line 970)

- access: public
- see: TDbLogRoute::setLogTableName()

void setAutoCreateLogTable (boolean $value)

- boolean $value: whether the log DB table should be automatically created if not exists.

setConnectionID (line 929)

Sets the ID of a TDataSourceConfig module.

The datasource module will be used to establish the DB connection for this log route.

- access: public

void setConnectionID (string $value)

- string $value: ID of the TDataSourceConfig module

setLogTableName (line 952)

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)

- access: public
- see: TDbLogRoute::setAutoCreateLogTable()

void setLogTableName (string $value)

- string $value: the name of the DB table to store log content

#### Inherited Methods

Inherited From TLogRoute

> TLogRoute::collectLogs()
> TLogRoute::formatLogMessage()
> TLogRoute::getCategories()
> TLogRoute::getLevelName()
> TLogRoute::getLevels()
> TLogRoute::getLevelValue()
> TLogRoute::init()
> TLogRoute::processLogs()
> TLogRoute::setCategories()
> TLogRoute::setLevels()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

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()

Documentation generated on Mon, 22 Feb 2010 12:18:08 +0000 by phpDocumentor 1.3.0RC4