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

  • author: Qiang Xue <qiang.xue@gmail.com>
  • version: $Id: TLogRouter.php 2996 2011-06-20 15:24:57Z ctrlaltca@gmail.com $
  • since: 3.1.2

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

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

Destructor.

Disconnect the db connection.

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

Creates the DB connection.

  • return: the created DB connection
  • throws: TConfigurationException if module ID is invalid or empty
  • access: protected
TDbConnection createDbConnection (string 0)
  • string 0: the module ID for TDataSourceConfig
createDbTable (line 903)

Creates the DB table for storing log messages.

  • todo: create sequence for PostgreSQL
  • access: protected
void createDbTable ()
getAutoCreateLogTable (line 1001)
boolean getAutoCreateLogTable ()
getConnectionID (line 959)
  • return: the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
  • access: public
string getConnectionID ()
getDbConnection (line 949)
  • return: the DB connection instance
  • access: public
TDbConnection getDbConnection ()
getLogTableName (line 978)
string getLogTableName ()
init (line 859)

Initializes this module.

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

  • throws: TConfigurationException if the DB table does not exist.
  • access: public
void init (TXmlElement $config)
  • TXmlElement $config: configuration for this module, can be null

Redefinition of:
TLogRoute::init()
Initializes the route.
processLogs (line 885)

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

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

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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()

Documentation generated on Mon, 25 Jun 2012 14:38:39 +0200 by phpDocumentor 1.4.3