Automattic\WooCommerce\Internal\PushNotifications\Services

NotificationStepLogger::log_batch_step │ public │ WC 11.3.0

Records a step that covers several notifications at once, such as the single loopback request a batch is sent in.

Written under the module's own source, since a batch can span notification types and so belongs to no one type's source. The notifications it covers are named by identifier in the context.

Method of the class: NotificationStepLogger{}

No Hooks.

Returns

void. Nothing (null).

Usage

$NotificationStepLogger = new NotificationStepLogger();
$NotificationStepLogger->log_batch_step( $step, $outcome, $context ): void;
$step(string) (required)
Machine-readable step name, e.g. loopback_requested.
$outcome(string) (required)
Machine-readable outcome, e.g. ok.
$context(array)
Extra fields to store with the line.
Default: array()

Changelog

Since 11.3.0 Introduced.

NotificationStepLogger::log_batch_step() code WC 11.3.0

public function log_batch_step( string $step, string $outcome, array $context = array() ): void {
	try {
		if ( ! $this->is_active() ) {
			return;
		}

		$context['step']           = $step;
		$context['outcome']        = $outcome;
		$context['source']         = PushNotifications::FEATURE_NAME;
		$context['remote-logging'] = false;

		wc_get_logger()->info( self::format_message( $step, $outcome ), self::bound( $context ) );
	} catch ( Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
		// Deliberately ignored: a logging failure must not affect the send.
	}
}