Skip to content
Snippets Groups Projects
Commit 76337f96 authored by dyszczo's avatar dyszczo
Browse files

fix for namespaces

parent 3a510f17
No related branches found
No related tags found
2 merge requests!3Devel,!2Feature/tests
......@@ -2,3 +2,4 @@
.idea
composer.lock
build-coverage
src/docker-compose.yml
\ No newline at end of file
......@@ -20,7 +20,7 @@
"wimg/php-compatibility": "^8"
},
"autoload": {
"psr-4": {"WPDesk\\Logs\\": "src/"}
"psr-4": {"WPDesk\\Logger\\": "src/"}
},
"autoload-dev": {
},
......
......@@ -9,7 +9,7 @@
<filter>
<whitelist>
<directory suffix=".php">classes</directory>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
......
<?php
namespace WPDesk\Logger\WP\Exception;
namespace WPDesk\Logger\WC\Exception;
class WCLoggerAlreadyCaptured extends \RuntimeException
......
<?php
namespace WPDesk\Logger\WP;
namespace WPDesk\Logger\WC;
use Monolog\Logger;
use WPDesk\Logger\WP\Exception\WCLoggerAlreadyCaptured;
use WPDesk\Logger\WC\Exception\WCLoggerAlreadyCaptured;
/**
* Can capture default WooCommerce logger
......@@ -20,7 +20,7 @@ class WooCommerceCapture
*
* @var bool
*/
private static $WCLoggerCaptured = false;
private $isCaptured = false;
/**
* Our monolog
......@@ -76,7 +76,7 @@ class WooCommerceCapture
*/
public function captureWcLogger()
{
if (self::$WCLoggerCaptured) {
if ($this->isCaptured) {
throw new WCLoggerAlreadyCaptured('Try to free wc logger first.');
}
......@@ -87,7 +87,7 @@ class WooCommerceCapture
remove_filter(self::WOOCOMMERCE_LOGGER_FILTER, $this->freeHookFunction);
add_filter(self::WOOCOMMERCE_LOGGER_FILTER, $this->captureHookFunction);
self::$WCLoggerCaptured = true;
$this->isCaptured = true;
} elseif (function_exists('add_action')) {
add_action(self::WOOCOMMERCE_AFTER_IS_LOADED_ACTION, [$this, 'captureWcLogger']);
} else {
......@@ -125,11 +125,11 @@ class WooCommerceCapture
*/
public function freeWcLogger()
{
if (self::$WCLoggerCaptured) {
if ($this->isCaptured) {
remove_filter(self::WOOCOMMERCE_LOGGER_FILTER, $this->captureHookFunction);
add_filter(self::WOOCOMMERCE_LOGGER_FILTER, $this->freeHookFunction);
self::$WCLoggerCaptured = false;
$this->isCaptured = false;
}
}
}
<?php
namespace WPDesk\Logger\WP;
namespace WPDesk\Logger\WC;
use Monolog\Handler\AbstractProcessingHandler;
......
<?php
namespace WPDesk\Logger\WP;
namespace WPDesk\Logger\WC;
use Monolog\Logger;
use Psr\Log\LogLevel;
......
......@@ -7,7 +7,7 @@ use Monolog\Registry;
use Monolog\ErrorHandler;
use Monolog\Handler\StreamHandler;
use Psr\Log\LogLevel;
use WPDesk\Logger\WP\WooCommerceCapture;
use WPDesk\Logger\WC\WooCommerceCapture;
/**
* Manages and facilitates creation of logger
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment