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

Merge branch 'bugfix/default-channel'

parents 68bc278c fd35bbc9
No related branches found
No related tags found
1 merge request!19Bugfix/default channel
Pipeline #7696 failed
## [Unreleased] ## [Unreleased]
### Fixed ### Fixed
- Fixed no handler actually assigned when using combination of - Fixed no handler actually assigned when using combination of NullHandler and actual one
NullHandler and actual one - WooCommerce channel is now taken from logger registered channel
## [1.7.1] - 2022-04-15 ## [1.7.1] - 2022-04-15
### Fixed ### Fixed
......
...@@ -36,7 +36,7 @@ final class SimpleLoggerFactory implements LoggerFactory { ...@@ -36,7 +36,7 @@ final class SimpleLoggerFactory implements LoggerFactory {
$logger->pushHandler( $logger->pushHandler(
new WooCommerceHandler( new WooCommerceHandler(
\wc_get_logger(), \wc_get_logger(),
$this->options->levels $this->channel
) )
); );
} }
......
...@@ -14,17 +14,23 @@ class WooCommerceHandler extends AbstractProcessingHandler { ...@@ -14,17 +14,23 @@ class WooCommerceHandler extends AbstractProcessingHandler {
/** @var \WC_Logger_Interface */ /** @var \WC_Logger_Interface */
private $wc_logger; private $wc_logger;
/** @var string */
private $channel;
/** /**
* Writes the record down to the log of the implementing handler * Writes the record down to the log of the implementing handler
* *
* @param array $record * @param array $record
* @return void * @return void
*/ */
protected function write(array $record) protected function write( array $record ) {
{ $context = array_merge(
$context = array_merge([ [
'source' => self::DEFAULT_WC_SOURCE 'source' => $this->channel;,
], $record['extra'], $record['context']); ],
$record['extra'],
$record['context']
);
$this->wc_logger->log( $this->convertMonologLevelToWC( $record['level'] ), $record['message'], $context ); $this->wc_logger->log( $this->convertMonologLevelToWC( $record['level'] ), $record['message'], $context );
} }
...@@ -37,8 +43,9 @@ class WooCommerceHandler extends AbstractProcessingHandler { ...@@ -37,8 +43,9 @@ class WooCommerceHandler extends AbstractProcessingHandler {
return Logger::getLevelName( $level ); return Logger::getLevelName( $level );
} }
public function __construct(\WC_Logger_Interface $originalWcLogger) { public function __construct( \WC_Logger_Interface $originalWcLogger, string $channel = self::DEFAULT_WC_SOURCE ) {
parent::__construct(); parent::__construct();
$this->wc_logger = $originalWcLogger; $this->wc_logger = $originalWcLogger;
$this->channel = $channel;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment