WooCommerce::log_errors()
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 (null).
Usage
$WooCommerce = new WooCommerce(); $WooCommerce->log_errors();
Changelog
Since 3.2.0 | Introduced. |
WooCommerce::log_errors() WooCommerce::log errors code WC 8.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 ) ) { $error_copy = $error; $message = $error_copy['message']; unset( $error_copy['message'] ); $context = array( 'source' => 'fatal-errors', 'error' => $error_copy, ); if ( false !== strpos( $message, 'Stack trace:' ) ) { $segments = explode( 'Stack trace:', $message ); $message = str_replace( PHP_EOL, ' ', trim( $segments[0] ) ); $backtrace = array_map( 'trim', explode( PHP_EOL, $segments[1] ) ); $context['backtrace'] = $backtrace; } else { $context['backtrace'] = true; } $logger = wc_get_logger(); $logger->critical( $message, $context ); /** * Action triggered when there are errors during shutdown. * * @since 3.2.0 */ do_action( 'woocommerce_shutdown_error', $error ); } }