Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CChainedLogFilter
  • CDbLogRoute
  • CEmailLogRoute
  • CFileLogRoute
  • CLogFilter
  • CLogger
  • CLogRoute
  • CLogRouter
  • CProfileLogRoute
  • CSysLogRoute
  • CWebLogRoute

Interfaces

  • ILogFilter
  • Overview
  • Package
  • Class
  • Tree

Class CLogger

CLogger records log messages in memory.

CLogger implements the methods to retrieve the messages with various filter conditions, including log levels and log categories.

CComponent
Extended by CLogger
Package: system\logging
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/logging/CLogger.php
Methods summary
public
# log( string $message, string $level = 'info', string $category = 'application' )

Logs a message. Messages logged by this method may be retrieved back via CLogger::getLogs().

Logs a message. Messages logged by this method may be retrieved back via CLogger::getLogs().

Parameters

$message
string
$message message to be logged
$level
string
$level level of the message (e.g. 'Trace', 'Warning', 'Error'). It is case-insensitive.
$category
string
$category category of the message (e.g. 'system.web'). It is case-insensitive.

See

CLogger::getLogs()
public array
# getLogs( string $levels = '', array|string $categories = array(), array|string $except = array() )

Retrieves log messages.

Retrieves log messages.

Messages may be filtered by log levels and/or categories. A level filter is specified by a list of levels separated by comma or space (e.g. 'trace, error'). A category filter is similar to level filter (e.g. 'system, system.web'). A difference is that in category filter you can use pattern like 'system.*' to indicate all categories starting with 'system'.

If you do not specify level filter, it will bring back logs at all levels. The same applies to category filter.

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

Parameters

$levels
string
$levels level filter
$categories
array|string
$categories category filter
$except
array|string
$except list of log categories to ignore

Returns

array
list of messages. Each array element represents one message with the following structure: array( [0] => message (string) [1] => level (string) [2] => category (string) [3] => timestamp (float, obtained by microtime(true));
public float
# getExecutionTime( )

Returns the total time for serving the current request. This method calculates the difference between now and the timestamp defined by constant YII_BEGIN_TIME. To estimate the execution time more accurately, the constant should be defined as early as possible (best at the beginning of the entry script.)

Returns the total time for serving the current request. This method calculates the difference between now and the timestamp defined by constant YII_BEGIN_TIME. To estimate the execution time more accurately, the constant should be defined as early as possible (best at the beginning of the entry script.)

Returns

float
the total time for serving the current request.
public integer
# getMemoryUsage( )

Returns the memory usage of the current application. This method relies on the PHP function memory_get_usage(). If it is not available, the method will attempt to use OS programs to determine the memory usage. A value 0 will be returned if the memory usage can still not be determined.

Returns the memory usage of the current application. This method relies on the PHP function memory_get_usage(). If it is not available, the method will attempt to use OS programs to determine the memory usage. A value 0 will be returned if the memory usage can still not be determined.

Returns

integer
memory usage of the application (in bytes).
public array
# getProfilingResults( string $token = null, string $categories = null, boolean $refresh = false )

Returns the profiling results. The results may be filtered by token and/or category. If no filter is specified, the returned results would be an array with each element being array($token,$category,$time). If a filter is specified, the results would be an array of timings.

Returns the profiling results. The results may be filtered by token and/or category. If no filter is specified, the returned results would be an array with each element being array($token,$category,$time). If a filter is specified, the results would be an array of timings.

Since 1.1.11, filtering results by category supports the same format used for filtering logs in CLogger::getLogs(), and similarly supports filtering by multiple categories and wildcard.

Parameters

$token
string
$token token filter. Defaults to null, meaning not filtered by token.
$categories
string
$categories category filter. Defaults to null, meaning not filtered by category.
$refresh
boolean
$refresh whether to refresh the internal timing calculations. If false, only the first time calling this method will the timings be calculated internally.

Returns

array
the profiling results.
public
# flush( boolean $dumpLogs = false )

Removes all recorded messages from the memory. This method will raise an CLogger::onFlush() event. The attached event handlers can process the log messages before they are removed.

Removes all recorded messages from the memory. This method will raise an CLogger::onFlush() event. The attached event handlers can process the log messages before they are removed.

Parameters

$dumpLogs
boolean
$dumpLogs whether to process the logs immediately as they are passed to log route

Since

1.1.0
public
# onFlush( CEvent $event )

Raises an onFlush event.

Raises an onFlush event.

Parameters

$event
CEvent
$event the event parameter

Since

1.1.0
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
string LEVEL_TRACE 'trace'
#
string LEVEL_WARNING 'warning'
#
string LEVEL_ERROR 'error'
#
string LEVEL_INFO 'info'
#
string LEVEL_PROFILE 'profile'
#
Properties summary
public integer $autoFlush 10000
#

how many messages should be logged before they are flushed to destinations. Defaults to 10,000, meaning for every 10,000 messages, the CLogger::flush() method will be automatically invoked once. If this is 0, it means messages will never be flushed automatically.

how many messages should be logged before they are flushed to destinations. Defaults to 10,000, meaning for every 10,000 messages, the CLogger::flush() method will be automatically invoked once. If this is 0, it means messages will never be flushed automatically.

Since

1.1.0
public boolean $autoDump false
#

this property will be passed as the parameter to CLogger::flush() when it is called in CLogger::log() due to the limit of CLogger::$autoFlush being reached. By default, this property is false, meaning the filtered messages are still kept in the memory by each log route after calling CLogger::flush(). If this is true, the filtered messages will be written to the actual medium each time CLogger::flush() is called within CLogger::log().

this property will be passed as the parameter to CLogger::flush() when it is called in CLogger::log() due to the limit of CLogger::$autoFlush being reached. By default, this property is false, meaning the filtered messages are still kept in the memory by each log route after calling CLogger::flush(). If this is true, the filtered messages will be written to the actual medium each time CLogger::flush() is called within CLogger::log().

Since

1.1.8
Magic properties summary
public array $logs
#

List of messages. Each array element represents one message with the following structure: array( [0] => message (string) [1] => level (string) [2] => category (string) [3] => timestamp (float, obtained by microtime(true));.

List of messages. Each array element represents one message with the following structure: array( [0] => message (string) [1] => level (string) [2] => category (string) [3] => timestamp (float, obtained by microtime(true));.

public float $executionTime
#

The total time for serving the current request.

The total time for serving the current request.

public integer $memoryUsage
#

Memory usage of the application (in bytes).

Memory usage of the application (in bytes).

public array $profilingResults
#

The profiling results.

The profiling results.

API documentation generated by ApiGen 2.8.0