Automattic\WooCommerce\Internal\BatchProcessing
BatchProcessingController::log_error()
Log an error that happened while processing a batch.
Метод класса: BatchProcessingController{}
Хуки из метода
Возвращает
null
. Ничего (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() BatchProcessingController::log error WC 9.4.2
protected function log_error( \Exception $error, BatchProcessorInterface $batch_processor, array $batch ): void { $error_message = "Error processing batch for {$batch_processor->get_name()}: {$error->getMessage()}"; $error_context = array( 'exception' => $error, 'source' => 'batch-processing', ); // Log only first and last, as the entire batch may be too big. if ( count( $batch ) > 0 ) { $error_context = array_merge( $error_context, array( 'batch_start' => $batch[0], 'batch_end' => end( $batch ), ) ); } /** * 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. * @param array $error_context Context to be passed to the logging function. * @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, $error_context ); $this->logger->error( $error_message, $error_context ); }