PHP 클래스 yii\log\Target

A log target object will filter the messages logged by Logger according to its [[levels]] and [[categories]] properties. It may also export the filtered messages to specific destination defined by the target, such as emails, files. Level filter and category filter are combinatorial, i.e., only messages satisfying both filter conditions will be handled. Additionally, you may specify [[except]] to exclude messages of certain categories.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$categories list of message categories that this target is interested in. Defaults to empty, meaning all categories. You can use an asterisk at the end of a category so that the category may be used to match those categories sharing the same common prefix. For example, 'yii\db\*' will match categories starting with 'yii\db\', such as 'yii\db\Connection'.
$enabled whether to enable this log target. Defaults to true.
$except list of message categories that this target is NOT interested in. Defaults to empty, meaning no uninteresting messages. If this property is not empty, then any category listed here will be excluded from [[categories]]. You can use an asterisk at the end of a category so that the category can be used to match those categories sharing the same common prefix. For example, 'yii\db\*' will match categories starting with 'yii\db\', such as 'yii\db\Connection'.
$exportInterval how many messages should be accumulated before they are exported. Defaults to 1000. Note that messages will always be exported when the application terminates. Set this property to be 0 if you don't want to export messages until the application terminates.
$logVars list of the PHP predefined variables that should be logged in a message. Note that a variable must be accessible via $GLOBALS. Otherwise it won't be logged. Defaults to ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_SERVER']. Since version 2.0.9 additional syntax can be used: Each element could be specified as one of the following: - var - var will be logged. - var.key - only var[key] key will be logged. - !var.key - var[key] key will be excluded.
$messages the messages that are retrieved from the logger so far by this log target. Please refer to [[Logger::messages]] for the details about the message structure.
$prefix a PHP callable that returns a string to be prefixed to every exported message. If not set, Target::getMessagePrefix will be used, which prefixes the message with context information such as user IP, user ID and session ID. The signature of the callable should be function ($message).

공개 메소드들

메소드 설명
collect ( array $messages, boolean $final ) Processes the given log messages.
export ( ) Exports log [[messages]] to a specific destination.
filterMessages ( array $messages, integer $levels, array $categories = [], array $except = [] ) : array Filters the given messages according to their categories and levels.
formatMessage ( array $message ) : string Formats a log message for display as a string.
getLevels ( ) : integer
getMessagePrefix ( array $message ) : string Returns a string to be prefixed to the given message.
setLevels ( array | integer $levels ) Sets the message levels that this target is interested in.

보호된 메소드들

메소드 설명
getContextMessage ( ) : string Generates the context information to be logged.

메소드 상세

collect() 공개 메소드

This method will filter the given messages with [[levels]] and [[categories]]. And if requested, it will also export the filtering result to specific medium (e.g. email).
public collect ( array $messages, boolean $final )
$messages array log messages to be processed. See [[Logger::messages]] for the structure of each message.
$final boolean whether this method is called at the end of the current application

export() 추상적인 공개 메소드

Child classes must implement this method.
abstract public export ( )

filterMessages() 공개 정적인 메소드

Filters the given messages according to their categories and levels.
public static filterMessages ( array $messages, integer $levels, array $categories = [], array $except = [] ) : array
$messages array messages to be filtered. The message structure follows that in [[Logger::messages]].
$levels integer the message levels to filter by. This is a bitmap of level values. Value 0 means allowing all levels.
$categories array the message categories to filter by. If empty, it means all categories are allowed.
$except array the message categories to exclude. If empty, it means all categories are allowed.
리턴 array the filtered messages.

formatMessage() 공개 메소드

Formats a log message for display as a string.
public formatMessage ( array $message ) : string
$message array the log message to be formatted. The message structure follows that in [[Logger::messages]].
리턴 string the formatted message

getContextMessage() 보호된 메소드

The default implementation will dump user information, system variables, etc.
protected getContextMessage ( ) : string
리턴 string the context information. If an empty string, it means no context information.

getLevels() 공개 메소드

public getLevels ( ) : integer
리턴 integer the message levels that this target is interested in. This is a bitmap of level values. Defaults to 0, meaning all available levels.

getMessagePrefix() 공개 메소드

If [[prefix]] is configured it will return the result of the callback. The default implementation will return user IP, user ID and session ID as a prefix.
public getMessagePrefix ( array $message ) : string
$message array the message being exported. The message structure follows that in [[Logger::messages]].
리턴 string the prefix string

setLevels() 공개 메소드

The parameter can be either an array of interested level names or an integer representing the bitmap of the interested level values. Valid level names include: 'error', 'warning', 'info', 'trace' and 'profile'; valid level values include: [[Logger::LEVEL_ERROR]], [[Logger::LEVEL_WARNING]], [[Logger::LEVEL_INFO]], [[Logger::LEVEL_TRACE]] and [[Logger::LEVEL_PROFILE]]. For example, php ['error', 'warning'] which is equivalent to: Logger::LEVEL_ERROR | Logger::LEVEL_WARNING
public setLevels ( array | integer $levels )
$levels array | integer message levels that this target is interested in.

프로퍼티 상세

$categories 공개적으로 프로퍼티

list of message categories that this target is interested in. Defaults to empty, meaning all categories. You can use an asterisk at the end of a category so that the category may be used to match those categories sharing the same common prefix. For example, 'yii\db\*' will match categories starting with 'yii\db\', such as 'yii\db\Connection'.
public $categories

$enabled 공개적으로 프로퍼티

whether to enable this log target. Defaults to true.
public $enabled

$except 공개적으로 프로퍼티

list of message categories that this target is NOT interested in. Defaults to empty, meaning no uninteresting messages. If this property is not empty, then any category listed here will be excluded from [[categories]]. You can use an asterisk at the end of a category so that the category can be used to match those categories sharing the same common prefix. For example, 'yii\db\*' will match categories starting with 'yii\db\', such as 'yii\db\Connection'.
또한 보기: categories
public $except

$exportInterval 공개적으로 프로퍼티

how many messages should be accumulated before they are exported. Defaults to 1000. Note that messages will always be exported when the application terminates. Set this property to be 0 if you don't want to export messages until the application terminates.
public $exportInterval

$logVars 공개적으로 프로퍼티

list of the PHP predefined variables that should be logged in a message. Note that a variable must be accessible via $GLOBALS. Otherwise it won't be logged. Defaults to ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_SERVER']. Since version 2.0.9 additional syntax can be used: Each element could be specified as one of the following: - var - var will be logged. - var.key - only var[key] key will be logged. - !var.key - var[key] key will be excluded.
또한 보기: yii\helpers\ArrayHelper::filter()
public $logVars

$messages 공개적으로 프로퍼티

the messages that are retrieved from the logger so far by this log target. Please refer to [[Logger::messages]] for the details about the message structure.
public $messages

$prefix 공개적으로 프로퍼티

a PHP callable that returns a string to be prefixed to every exported message. If not set, Target::getMessagePrefix will be used, which prefixes the message with context information such as user IP, user ID and session ID. The signature of the callable should be function ($message).
public $prefix