Automattic\WooCommerce\Internal\Admin\Logging
LogHandlerFileV2::handle
Handle a log entry.
Метод класса: LogHandlerFileV2{}
Хуков нет.
Возвращает
true|false. False if value was not handled and true if value was handled.
Использование
$LogHandlerFileV2 = new LogHandlerFileV2(); $LogHandlerFileV2->handle( $timestamp, $level, $message, $context );
- $timestamp(int) (обязательный)
- Log timestamp.
- $level(строка) (обязательный)
- emergency|alert|critical|error|warning|notice|info|debug.
- $message(строка) (обязательный)
- Log message.
- $context(массив) (обязательный)
Additional information for log handlers. Any data can be added here, but there are some array keys that have special behavior.
-
source(строка)
Determines which log file to write to. Must be at least 3 characters in length. - backtrace(true|false)
True to include a backtrace that shows where the logging function got called.
-
Код LogHandlerFileV2::handle() LogHandlerFileV2::handle WC 10.4.3
public function handle( $timestamp, $level, $message, $context ) {
$context = (array) $context;
if ( isset( $context['source'] ) && is_string( $context['source'] ) && strlen( $context['source'] ) >= 3 ) {
$source = sanitize_title( trim( $context['source'] ) );
} else {
$source = $this->determine_source();
}
$entry = static::format_entry( $timestamp, $level, $message, $context );
$written = $this->file_controller->write_to_file( $source, $entry, $timestamp );
if ( $written ) {
$this->file_controller->invalidate_cache();
}
return $written;
}