Automattic\WooCommerce\Internal\PushNotifications\Services

DriverAvailabilityService::write_log │ private │ WC 1.0

Writes the log entry for a swallowed throwable.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->write_log( $message, $e, ?LegacyProxy $proxy ): void;
$message(строка) (обязательный)
The message describing what was being determined.
$e(Throwable) (обязательный)
The caught throwable.
?LegacyProxy $proxy
.
По умолчанию: null

Код DriverAvailabilityService::write_log() WC 11.2.2

private function write_log( string $message, Throwable $e, ?LegacyProxy $proxy = null ): void {
	$proxy  = $proxy ?? wc_get_container()->get( LegacyProxy::class );
	$logger = $proxy->call_function( 'wc_get_logger' );

	if ( ! $logger instanceof WC_Logger_Interface ) {
		return;
	}

	$logger->error(
		sprintf(
			'%s (%s): %s',
			$message,
			$e instanceof Error ? 'error' : 'exception',
			$e->getMessage()
		),
		array( 'source' => PushNotifications::FEATURE_NAME )
	);
}