## Class TLogRoute

Description

TLogRoute class.

TLogRoute is the base class for all log route classes. A log route object retrieves log messages from a logger and sends it somewhere, such as files, emails. The messages being retrieved may be filtered first before being sent to the destination. The filters include log level filter and log category filter.

To specify level filter, set Levels property, which takes a string of comma-separated desired level names (e.g. 'Error, Debug'). To specify category filter, set Categories property, which takes a string of comma-separated desired category names (e.g. 'System.Web, System.IO').

Level filter and category filter are combinational, i.e., only messages satisfying both filter conditions will they be returned.

- abstract:
- since: 3.0
- 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 152)

    TComponent
       |
       --TApplicationComponent
          |
          --TLogRoute

Direct descendents

Class | Description
--- | ---
TFileLogRoute | TFileLogRoute class.
TEmailLogRoute | TEmailLogRoute class.
TBrowserLogRoute | TBrowserLogRoute class.
TDbLogRoute | TDbLogRoute class

Variable Summary
array $_levelNames
array $_levelValues
Method Summary
void collectLogs (TLogger $logger)
string formatLogMessage (string $message, integer $level, string $category, integer $time)
array getCategories ()
string getLevelName (integer $level)
integer getLevels ()
integer getLevelValue (string $level)
void init (TXmlElement $config)
void processLogs (array $logs)
void setCategories (array|string $categories)
void setLevels (integer|string $levels)
Variables
array $_levelNames = array(
TLogger::DEBUG=>'Debug',
TLogger::INFO=>'Info',
TLogger::NOTICE=>'Notice',
TLogger::WARNING=>'Warning',
TLogger::ERROR=>'Error',
TLogger::ALERT=>'Alert',
TLogger::FATAL=>'Fatal'
) (line 157)

- var: lookup table for level names
- static:
- access: protected

array $_levelValues = array(
'debug'=>TLogger::DEBUG,
'info'=>TLogger::INFO,
'notice'=>TLogger::NOTICE,
'warning'=>TLogger::WARNING,
'error'=>TLogger::ERROR,
'alert'=>TLogger::ALERT,
'fatal'=>TLogger::FATAL
) (line 169)

- var: lookup table for level values
- static:
- access: protected

Methods
collectLogs (line 287)

Retrieves log messages from logger to log route specific destination.

- access: public

void collectLogs (TLogger $logger)

- TLogger $logger: logger instance

formatLogMessage (line 278)

Formats a log message given different fields.

- return: formatted message
- access: protected

string formatLogMessage (string $message, integer $level, string $category, integer $time)

- string $message: message content
- integer $level: message level
- string $category: message category
- integer $time: timestamp

getCategories (line 228)

- return: list of categories to be looked for
- access: public

array getCategories ()
getLevelName (line 256)

- return: level name
- access: protected

string getLevelName (integer $level)

- integer $level: level value

getLevels (line 198)

- return: log level filter
- access: public

integer getLevels ()
getLevelValue (line 265)

- return: level value
- access: protected

integer getLevelValue (string $level)

- string $level: level name

init (line 191)

Initializes the route.

- access: public

void init (TXmlElement $config)

- TXmlElement $config: configurations specified in TLogRouter.

Redefined in descendants as:

- TEmailLogRoute::init() : Initializes the route.
- TDbLogRoute::init() : Initializes this module.

processLogs (line 305)

Processes log messages and sends them to specific destination.

Derived child classes must implement this method.

- access: protected
- abstract:

void processLogs (array $logs)

- array $logs: list of messages. Each array elements represents one message with the following structure: array( [0] => message [1] => level [2] => category [3] => timestamp);

Redefined in descendants as:

- TFileLogRoute::processLogs() : Saves log messages in files.
- TEmailLogRoute::processLogs() : Sends log messages to specified email addresses.
- TBrowserLogRoute::processLogs()
- TDbLogRoute::processLogs() : Stores log messages into database.

setCategories (line 237)

- access: public

void setCategories (array|string $categories)

- array|string $categories: list of categories to be looked for. If the value is a string, it is assumed to be comma-separated category names.

setLevels (line 208)

- access: public

void setLevels (integer|string $levels)

- integer|string $levels: integer log level filter (in bits). If the value is a string, it is assumed to be comma-separated level names. Valid level names include 'Debug', 'Info', 'Notice', 'Warning', 'Error', 'Alert' and 'Fatal'.

#### Inherited Methods

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:34 -0400 by phpDocumentor 1.3.0RC4