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:

  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
  • version: $Id: TLogRouter.php 2415 2008-03-24 20:39:47Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

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

TComponent
   |
   --TApplicationComponent
      |
      --TLogRoute
         |
         --TDbLogRoute
Method Summary
void __destruct ()
void createDbTable ()
string getConnectionID ()
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 729)

Destructor.

Disconnect the db connection.

  • access: public
void __destruct ()
createDbConnection (line 797)

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

Creates the DB table for storing log messages.

  • access: protected
void createDbTable ()
getAutoCreateLogTable (line 872)
boolean getAutoCreateLogTable ()
getConnectionID (line 830)
  • return: the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
  • access: public
string getConnectionID ()
getDbConnection (line 820)
  • return: the DB connection instance
  • access: public
TDbConnection getDbConnection ()
getLogTableName (line 849)
string getLogTableName ()
init (line 742)

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

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 881)
void setAutoCreateLogTable (boolean $value)
  • boolean $value: whether the log DB table should be automatically created if not exists.
setConnectionID (line 840)

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)
setLogTableName (line 863)

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)

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, 21 Apr 2008 11:35:32 -0400 by phpDocumentor 1.3.0RC4