Automattic\WooCommerce\Internal\Admin\BlockTemplates

BlockTemplateLogger::log_template_events_to_file()publicWC 1.0

Log all template events for a given template to the log file.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$BlockTemplateLogger = new BlockTemplateLogger();
$BlockTemplateLogger->log_template_events_to_file( $template_id );
$template_id(строка) (обязательный)
Template ID.

Код BlockTemplateLogger::log_template_events_to_file() WC 9.4.2

public function log_template_events_to_file( string $template_id ) {
	if ( ! isset( $this->all_template_events[ $template_id ] ) ) {
		return;
	}

	$template_events = $this->all_template_events[ $template_id ];

	$hash = $this->generate_template_events_hash( $template_events );

	if ( ! $this->has_template_events_changed( $template_id, $hash ) ) {
		// Nothing has changed since the last time this was logged,
		// so don't log it again.
		return;
	}

	$this->set_template_events_log_hash( $template_id, $hash );

	$template = $this->templates[ $template_id ];

	foreach ( $template_events as $template_event ) {
		$info = array_merge(
			array(
				'template'  => $template,
				'container' => $template_event['container'],
				'block'     => $template_event['block'],
			),
			$template_event['additional_info']
		);

		$message = $this->format_message( $template_event['message'], $info );

		$this->logger->log(
			$template_event['level'],
			$message,
			array( 'source' => 'block_template' )
		);
	}
}