PHP Класс yii\log\Dispatcher

Dispatcher implements the Dispatcher::dispatch-method that forwards the log messages from a Logger to the registered log [[targets]]. An instance of Dispatcher is registered as a core application component and can be accessed using Yii::$app->log. You may configure the targets in application configuration, like the following: php [ 'components' => [ 'log' => [ 'targets' => [ 'file' => [ 'class' => 'yii\log\FileTarget', 'levels' => ['trace', 'info'], 'categories' => ['yii\*'], ], 'email' => [ 'class' => 'yii\log\EmailTarget', 'levels' => ['error', 'warning'], 'message' => [ 'to' => '[email protected]', ], ], ], ], ], ] Each log target can have a name and can be referenced via the [[targets]] property as follows: php Yii::$app->log->targets['file']->enabled = false;
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\base\Component
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$targets the log targets. Each array element represents a single [[Target|log target]] instance or the configuration for creating the log target instance.

Открытые методы

Метод Описание
__construct ( $config = [] )
dispatch ( array $messages, boolean $final ) Dispatches the logged messages to [[targets]].
getFlushInterval ( ) : integer
getLogger ( ) : Logger Gets the connected logger.
getTraceLevel ( ) : integer
init ( )
setFlushInterval ( integer $value )
setLogger ( Logger | string | array $value ) Sets the connected logger.
setTraceLevel ( integer $value )

Описание методов

__construct() публичный Метод

public __construct ( $config = [] )

dispatch() публичный Метод

Dispatches the logged messages to [[targets]].
public dispatch ( array $messages, boolean $final )
$messages array the logged messages
$final boolean whether this method is called at the end of the current application

getFlushInterval() публичный Метод

public getFlushInterval ( ) : integer
Результат integer how many messages should be logged before they are sent to targets. This method returns the value of [[Logger::flushInterval]].

getLogger() публичный Метод

If not set, [[\Yii::getLogger()]] will be used.
public getLogger ( ) : Logger
Результат Logger the logger.

getTraceLevel() публичный Метод

public getTraceLevel ( ) : integer
Результат integer how many application call stacks should be logged together with each message. This method returns the value of [[Logger::traceLevel]]. Defaults to 0.

init() публичный Метод

public init ( )

setFlushInterval() публичный Метод

public setFlushInterval ( integer $value )
$value integer how many messages should be logged before they are sent to targets. This method will set the value of [[Logger::flushInterval]]. Defaults to 1000, meaning the [[Logger::flush()]] method will be invoked once every 1000 messages logged. Set this property to be 0 if you don't want to flush messages until the application terminates. This property mainly affects how much memory will be taken by the logged messages. A smaller value means less memory, but will increase the execution time due to the overhead of [[Logger::flush()]].

setLogger() публичный Метод

Sets the connected logger.
public setLogger ( Logger | string | array $value )
$value Logger | string | array the logger to be used. This can either be a logger instance or a configuration that will be used to create one using [[Yii::createObject()]].

setTraceLevel() публичный Метод

public setTraceLevel ( integer $value )
$value integer how many application call stacks should be logged together with each message. This method will set the value of [[Logger::traceLevel]]. If the value is greater than 0, at most that number of call stacks will be logged. Note that only application call stacks are counted. Defaults to 0.

Описание свойств

$targets публичное свойство

the log targets. Each array element represents a single [[Target|log target]] instance or the configuration for creating the log target instance.
public $targets