WooCommerce::log_errors()publicWC 3.2.0

Ensures fatal errors are logged so they can be picked up in the status report.

Method of the class: WooCommerce{}

Hooks from the method

Return

null. Nothing.

Usage

$WooCommerce = new WooCommerce();
$WooCommerce->log_errors();

Changelog

Since 3.2.0 Introduced.

WooCommerce::log_errors() code WC 7.7.0

public function log_errors() {
	$error = error_get_last();
	if ( $error && in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) {
		$logger = wc_get_logger();
		$logger->critical(
			/* translators: 1: error message 2: file name and path 3: line number */
			sprintf( __( '%1$s in %2$s on line %3$s', 'woocommerce' ), $error['message'], $error['file'], $error['line'] ) . PHP_EOL,
			array(
				'source' => 'fatal-errors',
			)
		);

		/**
		 * Action triggered when there are errors during shutdown.
		 *
		 * @since 3.2.0
		 */
		do_action( 'woocommerce_shutdown_error', $error );
	}
}