## 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: $Revision: $ $Date: $
- author: Qiang Xue <qiang.xue@gmail.com>

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

    TComponent
       |
       --TApplicationComponent
          |
          --TLogRoute

Direct descendents

Class | Description
--- | ---
TFileLogRoute | TFileLogRoute class.
TEmailLogRoute | TEmailLogRoute class.
TBrowserLogRoute | TBrowserLogRoute 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 155)

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

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

Methods
collectLogs (line 285)

Retrieves log messages from logger to log route specific destination.

- access: public

void collectLogs (TLogger $logger)

- TLogger $logger: logger instance

formatLogMessage (line 276)

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

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

array getCategories ()
getLevelName (line 254)

- return: level name
- access: protected

string getLevelName (integer $level)

- integer $level: level value

getLevels (line 196)

- return: log level filter
- access: public

integer getLevels ()
getLevelValue (line 263)

- return: level value
- access: protected

integer getLevelValue (string $level)

- string $level: level name

init (line 189)

Initializes the route.

- access: public

void init (TXmlElement $config)

- TXmlElement $config: configurations specified in TLogRouter.

Redefined in descendants as:

- TEmailLogRoute::init() : Initializes the route.

processLogs (line 303)

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

setCategories (line 235)

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

- 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::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> 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, 01 May 2006 23:04:06 -0400 by phpDocumentor 1.3.0RC4