Automattic\WooCommerce\Internal\Admin\Schedulers

ImportScheduler::log_import_errorprotected staticWC 1.0

Log details for an item that failed analytics import.

Method of the class: ImportScheduler{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = ImportScheduler::log_import_error( $item_id, $error, $context );
$item_id(int) (required)
Import item ID.
$error(Throwable) (required)
Error thrown during import.
$context(array)
Additional logger context.
Default: array()

ImportScheduler::log_import_error() code WC 10.9.1

final protected static function log_import_error( $item_id, \Throwable $error, array $context = array() ) {
	$logger      = wc_get_logger();
	$log_context = array_merge(
		array(
			'source' => 'wc-analytics-import',
		),
		$context,
		array(
			'scheduler'       => static::$name,
			'item_id'         => (int) $item_id,
			'exception_class' => get_class( $error ),
			'exception_file'  => $error->getFile(),
			'exception_line'  => $error->getLine(),
			'trace'           => $error->getTraceAsString(),
		)
	);

	$logger->error(
		sprintf(
			'Failed to import analytics item %1$d for %2$s: [%3$s] %4$s in %5$s:%6$d',
			$item_id,
			static::$name,
			get_class( $error ),
			$error->getMessage(),
			$error->getFile(),
			$error->getLine()
		),
		$log_context
	);
}