Merge pull request #20203 from woocommerce/update/20118

Log errors from transaction emails with logger
This commit is contained in:
Claudiu Lodromanean 2018-06-01 13:43:33 -07:00 committed by GitHub
commit c68b8faa99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -161,8 +161,16 @@ class WC_Emails {
self::instance(); // Init self so emails exist.
do_action_ref_array( current_filter() . '_notification', $args );
} catch ( Exception $e ) {
$error = 'Transactional email triggered fatal error for callback ' . current_filter();
$logger = wc_get_logger();
$logger->critical(
$error . PHP_EOL,
array(
'source' => 'transactional-emails',
)
);
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $error, E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
}