-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Verholen
committed
Jan 8, 2019
0 parents
commit 943d1ee
Showing
10 changed files
with
2,782 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.idea | ||
/vendor |
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,45 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Brandung\GelfLogger\Model; | ||
|
||
use Gelf\MessageInterface as Message; | ||
use Gelf\Transport\TransportInterface; | ||
use Gelf\Transport\UdpTransport; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
|
||
class ConfiguredUdpTransport implements TransportInterface | ||
{ | ||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
/** | ||
* @var UdpTransport | ||
*/ | ||
private $udpTransport; | ||
|
||
public function __construct(ScopeConfigInterface $scopeConfig) | ||
{ | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function send(Message $message): ?int | ||
{ | ||
try { | ||
return $this->getUdpTransport()->send($message); | ||
} catch (\Exception $e) { | ||
return -1; | ||
} | ||
} | ||
|
||
private function getUdpTransport(): UdpTransport | ||
{ | ||
if (null === $this->udpTransport) { | ||
$host = $this->scopeConfig->getValue('system/gelf_logger/host'); | ||
$port = $this->scopeConfig->getValue('system/gelf_logger/port'); | ||
$this->udpTransport = new UdpTransport($host, $port); | ||
} | ||
return $this->udpTransport; | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Brandung\GelfLogger\Model; | ||
|
||
use Gelf\PublisherInterface; | ||
use Monolog\Logger; | ||
|
||
class GelfHandler extends \Monolog\Handler\GelfHandler | ||
{ | ||
public function __construct(PublisherInterface $publisher, $level = Logger::DEBUG, $bubble = true) | ||
{ | ||
parent::__construct($publisher, $level, $bubble); | ||
} | ||
} |
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,26 @@ | ||
{ | ||
"name": "brandung/magento2-gelf-logger", | ||
"license": "MIT", | ||
"description": "Gelf Logger Handler", | ||
"require": { | ||
"php": "^7.1.0", | ||
"graylog2/gelf-php": "^1.6", | ||
"monolog/monolog": "^1.17", | ||
"magento/framework": "^101.0.6" | ||
}, | ||
"type": "magento2-module", | ||
"autoload": { | ||
"files": [ | ||
"./registration.php" | ||
], | ||
"psr-4": { | ||
"Brandung\\GelfLogger\\": "" | ||
} | ||
}, | ||
"repositories": { | ||
"magento": { | ||
"type": "composer", | ||
"url": "https://repo.magento.com" | ||
} | ||
} | ||
} |
Oops, something went wrong.