Skip to content
Snippets Groups Projects
Commit 68bc278c authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

Merge branch 'bugfix/no-handler' into 'master'

Bugfix/no handler

See merge request !18
parents dabf6516 f6efcb62
No related branches found
No related tags found
1 merge request!18Bugfix/no handler
Pipeline #7661 passed with stages
in 3 minutes and 1 second
## [Unreleased]
### Fixed
- Fixed no handler actually assigned when using combination of
NullHandler and actual one
## [1.7.1] - 2022-04-15 ## [1.7.1] - 2022-04-15
### Fixed ### Fixed
- Fixed the getLogger method from SimpleLoggerFactory - Fixed the getLogger method from SimpleLoggerFactory
......
...@@ -32,26 +32,23 @@ final class SimpleLoggerFactory implements LoggerFactory { ...@@ -32,26 +32,23 @@ final class SimpleLoggerFactory implements LoggerFactory {
$logger = new Logger( $this->channel ); $logger = new Logger( $this->channel );
$wc_handler = $this->get_wc_handler(); if ( $this->options->use_wc_log && \function_exists( 'wc_get_logger' ) ) {
if ( $this->options->use_wc_log ) { $logger->pushHandler(
$logger->pushHandler( $wc_handler ); new WooCommerceHandler(
\wc_get_logger(),
$this->options->levels
)
);
} }
if ( $this->options->use_wp_log || $wc_handler instanceof NullHandler ) { // Adding WooCommerce logger may have failed, if so add WP by default.
if ( $this->options->use_wp_log || empty( $logger->getHandlers() ) ) {
$logger->pushHandler( $this->get_wp_handler() ); $logger->pushHandler( $this->get_wp_handler() );
} }
return $this->logger = $logger; return $this->logger = $logger;
} }
private function get_wc_handler(): HandlerInterface {
if ( function_exists( 'wc_get_logger' ) ) {
return new WooCommerceHandler( wc_get_logger(), $this->options->level );
}
return new NullHandler();
}
private function get_wp_handler(): HandlerInterface { private function get_wp_handler(): HandlerInterface {
if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
return new ErrorLogHandler( ErrorLogHandler::OPERATING_SYSTEM, $this->options->level ); return new ErrorLogHandler( ErrorLogHandler::OPERATING_SYSTEM, $this->options->level );
......
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