Automattic\WooCommerce\Internal\PushNotifications\Services

NotificationStepLogger::write_error │ private │ WC 1.0

Writes one line to the module's own error source, swallowing any failure.

Method of the class: NotificationStepLogger{}

No Hooks.

Returns

void. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->write_error( $level, $message, $context ): void;
$level(string) (required)
error or warning.
$message(string) (required)
Human-readable message.
$context(array) (required)
Fields to store with the line.

NotificationStepLogger::write_error() code WC 11.3.0

private function write_error( string $level, string $message, array $context ): void {
	try {
		$context['source']         = PushNotifications::FEATURE_NAME;
		$context['remote-logging'] = false;

		wc_get_logger()->log( $level, self::clean( $message, self::MAX_MESSAGE_LENGTH ), self::bound( $context ) );
	} catch ( Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
		// Deliberately ignored: a logging failure must not affect the send.
	}
}