Skip to content

Commit

Permalink
20.7.0 MNB-2430 M2.4.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajosh committed May 13, 2022
1 parent 2f5ef8e commit 9914777
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ MNB-657 Remove logging per extension switches
MNB-5 Move to declarative schema


## 20.7.0 (2022-05-13)
MNB-2430 M2.4.4 compatibility


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ MNB-657 Remove logging per extension switches
MNB-5 Move to declarative schema


## 20.7.0 (2022-05-13)
MNB-2430 M2.4.4 compatibility


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-logger",
"description": "ShipperHQ Logger",
"type": "magento2-module",
"version": "20.6.0",
"version": "20.7.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
33 changes: 16 additions & 17 deletions src/Model/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public function __construct(
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function debug($message, array $context = [])
public function debug($message, array $context = []): void
{
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
return;
}

return $this->logMessage($message, $context, self::SEVERITY_NOTICE);
$this->logMessage($message, $context, self::SEVERITY_NOTICE);
}

/**
Expand All @@ -99,13 +99,13 @@ public function debug($message, array $context = [])
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function info($message, array $context = [])
public function info($message, array $context = []): void
{
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
return;
}

return $this->logMessage($message, $context, self::SEVERITY_MINOR);
$this->logMessage($message, $context, self::SEVERITY_MINOR);
}

/**
Expand All @@ -117,13 +117,13 @@ public function info($message, array $context = [])
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function warning($message, array $context = [])
public function warning($message, array $context = []): void
{
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
return;
}

return $this->logMessage($message, $context, self::SEVERITY_MAJOR);
$this->logMessage($message, $context, self::SEVERITY_MAJOR);
}

/**
Expand All @@ -135,16 +135,16 @@ public function warning($message, array $context = [])
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function critical($message, array $context = [])
public function critical($message, array $context = []): void
{
if (!$this->scopeConfig->getValue('shqlogmenu/shqlogger/active')) {
return false;
return;
}
return $this->logMessage($message, $context, self::SEVERITY_CRITICAL);
$this->logMessage($message, $context, self::SEVERITY_CRITICAL);
}


protected function logMessage($message, array $context = [], $severity)
protected function logMessage($message, array $context, $severity)
{
$adminLevel = $this->scopeConfig->getValue('shqlogmenu/shqlogger/admin_level');
$systemLogLevel = $this->scopeConfig->getValue('shqlogmenu/shqlogger/system_level');
Expand Down Expand Up @@ -175,21 +175,20 @@ protected function logMessage($message, array $context = [], $severity)
if ($emailLevel>0 && $emailLevel >= $severity) {
$this->logEmail($message, $context, $severity);
}
return true;
}

protected function logAdmin($message, array $context = [], $severity)
protected function logAdmin($message, array $context, $severity)
{
if (!is_array($message)) {
$message = explode('--', $message);
$message = explode('--', (string) $message);
}
if (is_array($message) && count($message) > 2) {
$newLog = $this->logFactory->create();
$newLog->parse($severity, $message[0], $message[1], $message[2]);
}
}

protected function logEmail($message, array $context = [], $severity)
protected function logEmail($message, array $context, $severity)
{
//To Do
}
Expand Down
32 changes: 16 additions & 16 deletions src/Observer/PostLogObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
*
* ShipperHQ
*
* NOTICE OF LICENSE
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category ShipperHQ
* @package ShipperHQ_Logger
Expand Down Expand Up @@ -100,25 +100,25 @@ public function execute(\Magento\Framework\Event\Observer $observer)
switch ($severity) {
case \ShipperHQ\Logger\Helper\Log::SEVERITY_NOTICE:
$this->logger->debug(var_export($code.' '.$url.' - '.$extension.' - '.$title, true));
if (!is_null($description) && $description!='') {
if ($description !== null && $description != '') {
$this->logger->debug(var_export($description, true));
}
break;
case \ShipperHQ\Logger\Helper\Log::SEVERITY_MINOR:
$this->logger->info(var_export($code.' '.$url.' - '.$extension.' - '.$title, true));
if (!is_null($description) && $description!='') {
if ($description !== null && $description != '') {
$this->logger->info(var_export($description, true));
}
break;
case \ShipperHQ\Logger\Helper\Log::SEVERITY_MAJOR:
$this->logger->warning(var_export($code.' '.$url.' - '.$extension.' - '.$title, true));
if (!is_null($description) && $description!='') {
if ($description !== null && $description != '') {
$this->logger->warning(var_export($description, true));
}
break;
case \ShipperHQ\Logger\Helper\Log::SEVERITY_CRITICAL:
$this->logger->critical(var_export($code.' '.$url.' - '.$extension.' - '.$title, true));
if (!is_null($description) && $description!='') {
if ($description !== null && $description != '') {
$this->logger->critical(var_export($description, true));
}
break;
Expand Down
33 changes: 17 additions & 16 deletions src/view/adminhtml/templates/view.phtml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<?php
/**
*
* ShipperHQ
* ShipperHQ
*
* NOTICE OF LICENSE
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category ShipperHQ
* @package ShipperHQ_Logger
* @copyright Copyright (c) 2019 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/
/** @var $block \ShipperHQ\Logger\Block\Adminhtml\Logger\View */
?>

<?php if($messageData = $this->getMessageData()): ?>
<?php if($messageData = $block->getMessageData()): ?>
<div class="page-head">
<h3><?php echo __('Message Details') ?></h3>
</div>
<div class="button-set"><a href="<?php echo $this->getBackUrl() ?>" class="left">&laquo; <?php echo __('Back to ShipperHQ Log') ?></a></div><br />
<div class="button-set"><a href="<?php echo $block->getBackUrl() ?>" class="left">&laquo; <?php echo __('Back to ShipperHQ Log') ?></a></div><br />
<div class="wsalogger-detail">
<p><strong><?php echo __('Code:') ?></strong> <?php echo $messageData->getCode(); ?></p>
<p><strong><?php echo __('Severity:') ?></strong> <?php echo $messageData->getSeverity(); ?></p>
Expand All @@ -43,5 +44,5 @@
</div>
</div>
<br />
<div class="button-set"><a href="<?php echo $this->getBackUrl() ?>" class="left">&laquo; <?php echo __('Back to ShipperHQ Log') ?></a></div><br />
<div class="button-set"><a href="<?php echo $block->getBackUrl() ?>" class="left">&laquo; <?php echo __('Back to ShipperHQ Log') ?></a></div><br />
<?php endif; ?>

0 comments on commit 9914777

Please sign in to comment.