Automattic\WooCommerce\Internal\Admin\BlockTemplates
BlockTemplateLogger::log_template_events_to_file
Log all template events for a given template to the log file.
Method of the class: BlockTemplateLogger{}
No Hooks.
Returns
null. Nothing (null).
Usage
$BlockTemplateLogger = new BlockTemplateLogger(); $BlockTemplateLogger->log_template_events_to_file( $template_id );
- $template_id(string) (required)
- Template ID.
BlockTemplateLogger::log_template_events_to_file() BlockTemplateLogger::log template events to file code WC 10.3.3
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' )
);
}
}