Automattic\WooCommerce\Internal\Admin\Logging

LogHandlerFileV2::format_entry()protected staticWC 1.0

Builds a log entry text from level, timestamp, and message.

Метод класса: LogHandlerFileV2{}

Хуки из метода

Возвращает

Строку. Formatted log entry.

Использование

$result = LogHandlerFileV2::format_entry( $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.

Код LogHandlerFileV2::format_entry() WC 9.5.1

protected static function format_entry( $timestamp, $level, $message, $context ) {
	$time_string  = static::format_time( $timestamp );
	$level_string = strtoupper( $level );

	if ( isset( $context['backtrace'] ) && true === filter_var( $context['backtrace'], FILTER_VALIDATE_BOOLEAN ) ) {
		$context['backtrace'] = static::get_backtrace();
	}

	$context_for_entry = $context;
	unset( $context_for_entry['source'] );

	if ( ! empty( $context_for_entry ) ) {
		$formatted_context = wp_json_encode( $context_for_entry, JSON_UNESCAPED_UNICODE );
		$message          .= stripslashes( " CONTEXT: $formatted_context" );
	}

	$entry = "$time_string $level_string $message";

	// phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment
	/** This filter is documented in includes/abstracts/abstract-wc-log-handler.php */
	return apply_filters(
		'woocommerce_format_log_entry',
		$entry,
		array(
			'timestamp' => $timestamp,
			'level'     => $level,
			'message'   => $message,
			'context'   => $context,
		)
	);
	// phpcs:enable WooCommerce.Commenting.CommentHooks.MissingSinceComment
}