diff --git a/Handler/RotatingFileHandler.php b/Handler/RotatingFileHandler.php index d091f05..336e8f4 100644 --- a/Handler/RotatingFileHandler.php +++ b/Handler/RotatingFileHandler.php @@ -67,7 +67,11 @@ public function __construct( public function getInstance(): HandlerInterface { return new \Monolog\Handler\RotatingFileHandler( - sprintf('%s/log/%s', $this->directoryList->getPath('var'), $this->scopeConfig->getValue($this->filenamePath)), + sprintf( + '%s/log/%s', + $this->directoryList->getPath(DirectoryList::VAR_DIR), + $this->scopeConfig->getValue($this->filenamePath) + ), $this->scopeConfig->getValue($this->maxFilesPath), $this->scopeConfig->getValue($this->levelPath) ); @@ -77,4 +81,4 @@ public function isEnabled(): bool { return (bool)$this->scopeConfig->getValue($this->isEnabled); } -} +} \ No newline at end of file diff --git a/Publisher/GelfPublisherWrapper.php b/Publisher/GelfPublisherWrapper.php deleted file mode 100644 index e69de29..0000000 diff --git a/Transport/UdpTransportWrapper.php b/Transport/UdpTransportWrapper.php index 3708687..bfd24d8 100755 --- a/Transport/UdpTransportWrapper.php +++ b/Transport/UdpTransportWrapper.php @@ -14,6 +14,8 @@ use Gelf\Transport\UdpTransportFactory; use Magento\Framework\App\Config\ScopeConfigInterface; +use in_array; + /** * Class UdpTransportWrapper * @@ -52,26 +54,24 @@ class UdpTransportWrapper implements TransportInterface private $transportFactory; /** - * UdpTransportWrapper constructor. - * - * @param UdpTransportFactory $transportFactory - * @param ScopeConfigInterface $scopeConfig - * @param string $hostPath - * @param string $portPath - * @param string $chunkSize + * @var string[] */ + private $ignoredMessages; + public function __construct( UdpTransportFactory $transportFactory, ScopeConfigInterface $scopeConfig, string $hostPath, string $portPath, - string $chunkSize = UdpTransport::CHUNK_SIZE_LAN + string $chunkSize = UdpTransport::CHUNK_SIZE_LAN, + array $ignoredMessages = [] ) { $this->scopeConfig = $scopeConfig; $this->hostPath = $hostPath; $this->portPath = $portPath; $this->chunkSize = $chunkSize; $this->transportFactory = $transportFactory; + $this->ignoredMessages = $ignoredMessages; } /** @@ -83,6 +83,10 @@ public function __construct( */ public function send(Message $message): int { + if (in_array($message->getShortMessage(), $this->ignoredMessages, true)) { + return 0; + } + return $this->getTransporter()->send($message); } @@ -101,4 +105,4 @@ private function getTransporter(): UdpTransport return $this->transporter; } -} +} \ No newline at end of file