Skip to content
Snippets Groups Projects
Verified Commit 11675bda authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

feat: use WordPress log as fallback


Following previous commit, remove check for WP log usage, and treat it
only as fallback handler.

Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent c8be4966
No related branches found
No related tags found
1 merge request!29feat/message handling
Pipeline #393172 passed with warnings with stages
in 31 seconds
...@@ -44,9 +44,13 @@ final class SimpleLoggerFactory implements LoggerFactory { ...@@ -44,9 +44,13 @@ final class SimpleLoggerFactory implements LoggerFactory {
\add_action( 'woocommerce_init', [ $this, 'create_wc_handler' ] ); \add_action( 'woocommerce_init', [ $this, 'create_wc_handler' ] );
} }
// Adding WooCommerce logger may have failed, if so add WP by default. // In the worst-case scenario, when WC logs are not available (yet, or at all),
if ( empty( $this->logger->getHandlers() ) ) { // fallback to WP logs, but only when enabled.
$this->logger->pushHandler( $this->get_wp_handler() ); if ( empty( $this->logger->getHandlers() ) && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
$this->set_handler(
$this->logger,
new ErrorLogHandler( ErrorLogHandler::OPERATING_SYSTEM, $this->options['level'] );
);
} }
return $this->logger; return $this->logger;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment