Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::log_error()protectedWC 1.0

Log an error that happened while processing a batch.

{} Это метод класса: BatchProcessingController{}

Хуки из метода

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->log_error( $error, $batch_processor, $batch ) : void;
$error(\Exception) (обязательный)
Exception object to log.
$batch_processor(BatchProcessorInterface) (обязательный)
Batch processor instance.
$batch(массив) (обязательный)
Batch that was being processed.

Код BatchProcessingController::log_error() WC 6.9.4

protected function log_error( \Exception $error, BatchProcessorInterface $batch_processor, array $batch ) : void {
	$batch_detail_string = '';
	// Log only first and last, as the entire batch may be too big.
	if ( count( $batch ) > 0 ) {
		// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- Logging is for debugging.
		$batch_detail_string = '\n' . print_r(
			array(
				'batch_start' => $batch[0],
				'batch_end'   => end( $batch ),
			),
			true
		);
	}
	$error_message = "Error processing batch for {$batch_processor->get_name()}: {$error->getMessage()}" . $batch_detail_string;

	/**
	 * Filters the error message for a batch processing.
	 *
	 * @param string $error_message The error message that will be logged.
	 * @param \Exception $error The exception that was thrown by the processor.
	 * @param BatchProcessorInterface $batch_processor The processor that threw the exception.
	 * @param array $batch The batch that was being processed.
	 * @return string The actual error message that will be logged.
	 *
	 * @since 6.8.0
	 */
	$error_message = apply_filters( 'wc_batch_processing_log_message', $error_message, $error, $batch_processor, $batch );

	$this->logger->error( $error_message, array( 'exception' => $error ) );
}