Automattic\WooCommerce\Internal\PushNotifications\Services

NotificationStepLogger::write │ private │ WC 1.0

Writes one line, swallowing any failure so logging can never break a send.

The source is built here rather than by the caller, because get_notification_source() runs sanitize_title() and its public filter.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->write( $notification, $step, $outcome, $context, $suppressed ): void;
$notification(Notification) (обязательный)
The notification the step belongs to.
$step(строка) (обязательный)
Machine-readable step name.
$outcome(строка) (обязательный)
Machine-readable outcome.
$context(массив) (обязательный)
Extra fields to store with the line.
$suppressed(true|false)
True to write to the store-wide suppressed source instead of the notification type's.
По умолчанию: false

Код NotificationStepLogger::write() WC 11.3.0

private function write( Notification $notification, string $step, string $outcome, array $context, bool $suppressed = false ): void {
	try {
		if ( ! $this->is_active() ) {
			return;
		}

		$context = self::bound( self::identify( $notification, $step, $outcome, $context ) );

		$context['source'] = $suppressed
			? self::SUPPRESSED_SOURCE
			: self::get_notification_source( $notification );

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