-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from MeCapron/feature/add_slack_logger
Feature/add slack logger
- Loading branch information
Showing
28 changed files
with
888 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Config; | ||
|
||
use \Magento\Framework\App\Helper\AbstractHelper; | ||
use Magento\Framework\App\Helper\AbstractHelper; | ||
|
||
/** | ||
* Class Config | ||
* @package Opengento\Logger\Config | ||
*/ | ||
class Config extends AbstractHelper | ||
{ | ||
/** Config keys */ | ||
const CONFIG_LOGGER_CUSTOM_CONFIGURATION = 'loggin/loggin/types_logger'; | ||
} | ||
public const CONFIG_LOGGER_CUSTOM_CONFIGURATION = 'loggin/context/types_logger'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,48 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Config; | ||
|
||
/** | ||
* Class CustomConfiguration | ||
*/ | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
use Magento\Store\Model\ScopeInterface; | ||
|
||
class CustomConfiguration | ||
{ | ||
/** | ||
* @var \Magento\Framework\App\Config\ScopeConfigInterface | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* @var \Magento\Framework\Serialize\Serializer\Json | ||
* @var Json | ||
*/ | ||
private $serializer; | ||
|
||
|
||
/** | ||
* CustomFields constructor. | ||
* @param \Magento\Framework\App\Helper\Context $context | ||
* @param \Magento\Framework\Serialize\Serializer\Json $serializer | ||
*/ | ||
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Serialize\Serializer\Json $serializer) | ||
public function __construct(ScopeConfigInterface $scopeConfig, Json $serializer) | ||
{ | ||
$this->scopeConfig = $scopeConfig; | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* @param $configPath | ||
* @param null $store | ||
* @return mixed | ||
*/ | ||
public function getConfigValue($configPath, $store = null){ | ||
return $this->scopeConfig->getValue( | ||
$configPath, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, | ||
$store | ||
); | ||
} | ||
|
||
/** | ||
* @param $configPath | ||
* @param null $store | ||
* @return array|bool|float|int|mixed|string|null | ||
*/ | ||
public function getUnserializedConfigValue($configPath, $store = null){ | ||
public function getUnserializedConfigValue(string $configPath, ?string $store = null): ?array | ||
{ | ||
$value = $this->getConfigValue($configPath, $store); | ||
|
||
if(!$value) return false; | ||
if (!$value) { | ||
return null; | ||
} | ||
|
||
return $this->serializer->unserialize($value); | ||
} | ||
} | ||
|
||
public function getConfigValue(string $configPath, ?string $store = null) | ||
{ | ||
return $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $store); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Monolog\Logger; | ||
|
||
class LoggingLevel implements OptionSourceInterface | ||
{ | ||
public function toOptionArray(): array | ||
{ | ||
return [ | ||
['value' => Logger::DEBUG, 'label' => __('Debug')], | ||
['value' => Logger::INFO, 'label' => __('Info')], | ||
['value' => Logger::NOTICE, 'label' => __('Notice')], | ||
['value' => Logger::WARNING, 'label' => __('Warning')], | ||
['value' => Logger::ERROR, 'label' => __('Error')], | ||
['value' => Logger::CRITICAL, 'label' => __('Critical')], | ||
['value' => Logger::ALERT, 'label' => __('Alert')], | ||
['value' => Logger::EMERGENCY, 'label' => __('Emergency')], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Handler; | ||
|
||
use Exception; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Monolog\Handler\HandlerInterface; | ||
use Monolog\Handler\StreamHandler; | ||
|
||
class ConsoleHandler implements MagentoHandlerInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $isEnabled; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $levelPath; | ||
|
||
public function __construct( | ||
ScopeConfigInterface $scopeConfig, | ||
string $isEnabled, | ||
string $levelPath | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
$this->isEnabled = $isEnabled; | ||
$this->levelPath = $levelPath; | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function getInstance(): HandlerInterface | ||
{ | ||
return new StreamHandler( | ||
'php://stdout', | ||
$this->scopeConfig->getValue($this->levelPath) | ||
); | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return (bool)$this->scopeConfig->getValue($this->isEnabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Handler; | ||
|
||
use Gelf\PublisherInterface; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Monolog\Handler\GelfHandler as MonologGelfHandler; | ||
use Monolog\Handler\HandlerInterface; | ||
|
||
class GelfHandler implements MagentoHandlerInterface | ||
{ | ||
/** | ||
* @var PublisherInterface | ||
*/ | ||
private $publisher; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $isEnabled; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $levelPath; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
public function __construct( | ||
PublisherInterface $publisher, | ||
ScopeConfigInterface $scopeConfig, | ||
string $isEnabled, | ||
string $levelPath | ||
) { | ||
$this->publisher = $publisher; | ||
$this->isEnabled = $isEnabled; | ||
$this->levelPath = $levelPath; | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function getInstance(): HandlerInterface | ||
{ | ||
return new MonologGelfHandler( | ||
$this->publisher, | ||
$this->scopeConfig->getValue($this->levelPath) | ||
); | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return (bool)$this->scopeConfig->getValue($this->isEnabled); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Opengento\Logger\Handler; | ||
|
||
use Monolog\Handler\HandlerInterface; | ||
|
||
interface MagentoHandlerInterface | ||
{ | ||
public function getInstance(): HandlerInterface; | ||
|
||
public function isEnabled(): bool; | ||
} |
Oops, something went wrong.