Logger

Type
Class
Namespace
Craft
Inherits
Craft\Logger » CLogger (opens new window) » CComponent (opens new window)
Since
1.0

Class Logger

See also http://craftcms.com

View source (opens new window)

# Public Properties

# $autoDump

Signature

public boolean $autoDump = true

# $autoFlush

Signature

public integer $autoFlush = 0

# Protected Properties

Property Description
$_categories (opens new window) array (opens new window) – Log categories for filtering (used when filtering)
$_except (opens new window) array (opens new window) – Log categories for excluding from filtering (used when filtering)
$_levels (opens new window) array (opens new window) – Log levels for filtering (used when filtering)
$_logCount (opens new window) integer (opens new window) – Number of log messages
$_logs (opens new window) array (opens new window) – Log messages
$_processing (opens new window) boolean (opens new window) – If we are processing the log or still accepting new log messages
$_timings (opens new window) array (opens new window) – The profiling results (category, token => time in seconds)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__unset() (opens new window) Sets a component property to be null.
asa() (opens new window) Returns the named behavior object.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
flush() (opens new window) Removes all recorded messages from the memory.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getExecutionTime() (opens new window) Returns the total time for serving the current request.
getLogs() Retrieves log messages.
getMemoryUsage() (opens new window) Returns the memory usage of the current application.
getProfilingResults() (opens new window) Returns the profiling results.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasProperty() (opens new window) Determines whether a property is defined.
log() Logs a message. Messages logged by this method may be retrieved back via {@link getLogs}.
onFlush() (opens new window) Raises an onFlush event.
raiseEvent() (opens new window) Raises an event.

# getLogs()

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.

View source (opens new window)

Arguments

Returns

array (opens new window) – The 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)
);

Signature

public array getLogs ( $levels = '', $categories = [], $except = [] )

# log()

Logs a message. Messages logged by this method may be retrieved back via {@link getLogs}.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null log ( $message, $level = 'info', $force = false, $category = 'application', $plugin = null )

# Protected Methods

Method Description
filterAllCategories() Filter function used to filter included and excluded categories
filterByCategory() Filter function used by {@link getLogs}
filterByLevel() Filter function used by {@link getLogs}

# filterAllCategories()

Filter function used to filter included and excluded categories

View source (opens new window)

Arguments

Returns

boolean (opens new window) – True if valid timing entry, false if not.

Signature

protected boolean filterAllCategories ( $value, $index )

# filterByCategory()

Filter function used by {@link getLogs}

View source (opens new window)

Arguments

Returns

boolean (opens new window) – True if valid log, false if not.

Signature

protected boolean filterByCategory ( $value )

# filterByLevel()

Filter function used by {@link getLogs}

View source (opens new window)

Arguments

Returns

boolean (opens new window) – True if valid log, false if not.

Signature

protected boolean filterByLevel ( $value )

# Constants

Constant Description
LEVEL_ERROR
LEVEL_INFO
LEVEL_PROFILE
LEVEL_TRACE
LEVEL_WARNING