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.

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

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

TComponent
   |
   --TApplicationComponent
      |
      --TLogRoute
Direct descendents
Class Description
TFileLogRoute TFileLogRoute class.
TEmailLogRoute TEmailLogRoute class.
TBrowserLogRoute TBrowserLogRoute class.
TDbLogRoute TDbLogRoute class
TFirePhpLogRoute TFirePhpLogRoute class.
Variable Summary
static array $_levelNames
static 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
static 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 202)
  • var: lookup table for level names
  • access: protected
static 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 214)
  • var: lookup table for level values
  • access: protected
Methods
collectLogs (line 332)

Retrieves log messages from logger to log route specific destination.

  • access: public
void collectLogs (TLogger $logger)
formatLogMessage (line 323)

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 273)
  • return: list of categories to be looked for
  • access: public
array getCategories ()
getLevelName (line 301)
  • return: level name
  • access: protected
string getLevelName (integer $level)
  • integer $level: level value
getLevels (line 243)
  • return: log level filter
  • access: public
integer getLevels ()
getLevelValue (line 310)
  • return: level value
  • access: protected
integer getLevelValue (string $level)
  • string $level: level name
init (line 236)

Initializes the route.

  • access: public
void init (TXmlElement $config)

Redefined in descendants as:
processLogs (line 350)

Processes log messages and sends them to specific destination.

Derived child classes must implement this method.

  • abstract:
  • access: protected
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:
setCategories (line 282)
  • 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 253)
  • 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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()

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