Skip to content

Commit

Permalink
20.3.0 SHQ18-112 use Magento scope config
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajason committed Mar 21, 2018
1 parent 22d211f commit 263b334
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
17 changes: 12 additions & 5 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Change Log

## [20.3.0](https://github.com/webshopapps/module-logger/tree/20.3.0) (2018-03-21)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.2.0...20.3.0)

**Merged pull requests:**

- SHQ18-112 Remove dependency on Common\Helper\Data [\#2](https://github.com/webshopapps/module-logger/pull/2) ([wsagen](https://github.com/wsagen))

## [20.2.0](https://github.com/webshopapps/module-logger/tree/20.2.0) (2017-12-01)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.1...20.2.0)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.2...20.2.0)

**Merged pull requests:**

- SHQ16-2432 Code sniffer changes [\#1](https://github.com/webshopapps/module-logger/pull/1) ([wsagen](https://github.com/wsagen))

## [20.1.2](https://github.com/webshopapps/module-logger/tree/20.1.2) (2017-03-10)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.1...20.1.2)

## [20.1.1](https://github.com/webshopapps/module-logger/tree/20.1.1) (2017-03-10)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.0...20.1.1)

## [20.1.0](https://github.com/webshopapps/module-logger/tree/20.1.0) (2017-03-10)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.3...20.1.0)

## [20.1.3](https://github.com/webshopapps/module-logger/tree/20.1.3) (2017-03-10)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/20.1.2...20.1.3)

## [20.1.2](https://github.com/webshopapps/module-logger/tree/20.1.2) (2017-03-10)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/1.2.9...20.1.2)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/1.2.9...20.1.3)

## [1.2.9](https://github.com/webshopapps/module-logger/tree/1.2.9) (2017-02-14)
[Full Changelog](https://github.com/webshopapps/module-logger/compare/1.2.8...1.2.9)
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"name": "Zowta LLC"
}
],

"require": {
"magento/framework": "^100.0",
"shipperhq/module-common": "*"
},
"support": {
"documentation": "http://docs.shipperhq.com"
},
Expand Down
30 changes: 16 additions & 14 deletions src/Model/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

namespace ShipperHQ\Logger\Model;

use \Magento\Framework\App\Config\ScopeConfigInterface;

/**
* ShipperHQ Logger implementation
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
Expand All @@ -48,31 +50,31 @@ class Logger extends \Monolog\Logger
const SEVERITY_NONE = -1;

/**
* @var \ShipperHQ\Common\Helper\Data
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $helper;
private $scopeConfig;
/**
* @var \ShipperHQ\Shipper\Model\SynchronizeFactory
*/
private $logFactory;

/**
* @param LogFactory $logFactory
* @param \ShipperHQ\Common\Helper\Data $dataHelper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param string $name The logging channel
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
* @param callable[] $processors Optional array of processors
*/
public function __construct(
LogFactory $logFactory,
\ShipperHQ\Common\Helper\Data $dataHelper,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
$name,
array $handlers = [],
array $processors = []
) {

$this->logFactory = $logFactory;
$this->helper = $dataHelper;
$this->scopeConfig = $scopeConfig;
parent::__construct($name, $handlers, $processors);
}

Expand All @@ -87,7 +89,7 @@ public function __construct(
*/
public function debug($message, array $context = [])
{
if (!$this->helper->getConfigValue('shqlogmenu/shqlogger/active')) {
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
}

Expand All @@ -105,7 +107,7 @@ public function debug($message, array $context = [])
*/
public function info($message, array $context = [])
{
if (!$this->helper->getConfigValue('shqlogmenu/shqlogger/active')) {
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
}

Expand All @@ -123,7 +125,7 @@ public function info($message, array $context = [])
*/
public function warning($message, array $context = [])
{
if (!$this->helper->getConfigValue('shqlogmenu/shqlogger/active')) {
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
}

Expand All @@ -141,7 +143,7 @@ public function warning($message, array $context = [])
*/
public function critical($message, array $context = [])
{
if (!$this->helper->getConfigValue('shqlogmenu/shqlogger/active')) {
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
}
return $this->logMessage($message, $context, self::SEVERITY_CRITICAL);
Expand All @@ -150,9 +152,9 @@ public function critical($message, array $context = [])

protected function logMessage($message, array $context = [], $severity)
{
$adminLevel = $this->helper->getConfigValue('shqlogmenu/shqlogger/admin_level');
$systemLogLevel = $this->helper->getConfigValue('shqlogmenu/shqlogger/system_level');
$emailLevel = $this->helper->getConfigValue('shqlogmenu/shqlogger/email_level');
$adminLevel = $this->scopeConfig->getValue('shqlogmenu/shqlogger/admin_level');
$systemLogLevel = $this->scopeConfig->getValue('shqlogmenu/shqlogger/system_level');
$emailLevel = $this->scopeConfig->getValue('shqlogmenu/shqlogger/email_level');

if ($adminLevel>0 && $adminLevel >= $severity) {
$this->logAdmin($message, $context, $severity);
Expand Down Expand Up @@ -203,6 +205,6 @@ protected function isDebug($moduleName)
$path = 'shqlogmenu/shq_module_log/'.$moduleName;
parent::debug('the path to config setting ', [$path]);

return $this->helper->getConfigValue($path) ? true : false;
return $this->scopeConfig->getValue($path) ? true : false;
}
}

0 comments on commit 263b334

Please sign in to comment.