diff --git a/doc/02-handlers-formatters-processors.md b/doc/02-handlers-formatters-processors.md index 29f1f55d..93dc58dd 100644 --- a/doc/02-handlers-formatters-processors.md +++ b/doc/02-handlers-formatters-processors.md @@ -136,6 +136,7 @@ - [_LogglyFormatter_](../src/Monolog/Formatter/LogglyFormatter.php): Used to format log records into Loggly messages, only useful for the LogglyHandler. - [_FlowdockFormatter_](../src/Monolog/Formatter/FlowdockFormatter.php): Used to format log records into Flowdock messages, only useful for the FlowdockHandler. - [_MongoDBFormatter_](../src/Monolog/Formatter/MongoDBFormatter.php): Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler. +- [_LogmaticFormatter_](../src/Monolog/Formatter/LogmaticFormatter.php): User to format log records to [Logmatic](http://logmatic.io/) messages, only useful for the LogmaticHandler. ## Processors diff --git a/src/Monolog/Formatter/JsonFormatter.php b/src/Monolog/Formatter/JsonFormatter.php index 4ed7243e..1a8fe0b4 100644 --- a/src/Monolog/Formatter/JsonFormatter.php +++ b/src/Monolog/Formatter/JsonFormatter.php @@ -150,7 +150,7 @@ class JsonFormatter extends NormalizerFormatter $normalized['...'] = 'Over 1000 items, aborting normalization'; break; } - $normalized[$key] = $this->normalize($value, $depth+1); + $normalized[$key] = $this->normalize($value, $depth + 1); } return $normalized; diff --git a/src/Monolog/Formatter/LogmaticFormatter.php b/src/Monolog/Formatter/LogmaticFormatter.php index 83b93019..2e103120 100644 --- a/src/Monolog/Formatter/LogmaticFormatter.php +++ b/src/Monolog/Formatter/LogmaticFormatter.php @@ -33,8 +33,9 @@ class LogmaticFormatter extends JsonFormatter * * @param string $hostname */ - public function setHostname(string $hostname) { - $this->hostname = $hostname; + public function setHostname(string $hostname) + { + $this->hostname = $hostname; } /** @@ -42,7 +43,8 @@ class LogmaticFormatter extends JsonFormatter * * @param string $appname */ - public function setAppname(string $appname) { + public function setAppname(string $appname) + { $this->appname = $appname; } diff --git a/src/Monolog/Formatter/NormalizerFormatter.php b/src/Monolog/Formatter/NormalizerFormatter.php index 08e10db5..fcac4a61 100644 --- a/src/Monolog/Formatter/NormalizerFormatter.php +++ b/src/Monolog/Formatter/NormalizerFormatter.php @@ -84,7 +84,7 @@ class NormalizerFormatter implements FormatterInterface $normalized['...'] = 'Over 1000 items, aborting normalization'; break; } - $normalized[$key] = $this->normalize($value, $depth+1); + $normalized[$key] = $this->normalize($value, $depth + 1); } return $normalized; diff --git a/src/Monolog/Handler/GroupHandler.php b/src/Monolog/Handler/GroupHandler.php index 38109e90..ef1485f4 100644 --- a/src/Monolog/Handler/GroupHandler.php +++ b/src/Monolog/Handler/GroupHandler.php @@ -76,7 +76,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface public function handleBatch(array $records) { if ($this->processors) { - $processed = array(); + $processed = []; foreach ($records as $record) { foreach ($this->processors as $processor) { $processed[] = call_user_func($processor, $record); diff --git a/src/Monolog/Handler/LogmaticHandler.php b/src/Monolog/Handler/LogmaticHandler.php index e78d3cf2..70c4d6ae 100644 --- a/src/Monolog/Handler/LogmaticHandler.php +++ b/src/Monolog/Handler/LogmaticHandler.php @@ -36,19 +36,19 @@ class LogmaticHandler extends SocketHandler protected $appname; /** - * @param string $hostname Host name supplied by Logmatic. - * @param string $appname Application name supplied by Logmatic. - * @param string $token Log token supplied by Logmatic. - * @param bool $useSSL Whether or not SSL encryption should be used. - * @param int $level The minimum logging level to trigger this handler. - * @param bool $bubble Whether or not messages that are handled should bubble up the stack. + * @param string $token Log token supplied by Logmatic. + * @param string $hostname Host name supplied by Logmatic. + * @param string $appname Application name supplied by Logmatic. + * @param bool $useSSL Whether or not SSL encryption should be used. + * @param int|string $level The minimum logging level to trigger this handler. + * @param bool $bubble Whether or not messages that are handled should bubble up the stack. * * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing */ - public function __construct($token, $hostname = '', $appname = '', $useSSL = true, $level = Logger::DEBUG, $bubble = true) + public function __construct(string $token, string $hostname = '', string $appname = '', bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true) { if ($useSSL && !extension_loaded('openssl')) { - throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogmaticHandler'); + throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler'); } $endpoint = $useSSL ? 'ssl://api.logmatic.io:10515' : 'api.logmatic.io:10514'; @@ -77,10 +77,10 @@ class LogmaticHandler extends SocketHandler $formatter = new LogmaticFormatter(); if (!empty($this->hostname)) { - $formatter->setHostname($this->hostname); + $formatter->setHostname($this->hostname); } if (!empty($this->appname)) { - $formatter->setAppname($this->appname); + $formatter->setAppname($this->appname); } return $formatter; diff --git a/src/Monolog/Handler/SwiftMailerHandler.php b/src/Monolog/Handler/SwiftMailerHandler.php index 549246d9..f4816b57 100644 --- a/src/Monolog/Handler/SwiftMailerHandler.php +++ b/src/Monolog/Handler/SwiftMailerHandler.php @@ -26,12 +26,12 @@ class SwiftMailerHandler extends MailHandler private $messageTemplate; /** - * @param \Swift_Mailer $mailer The mailer to use + * @param \Swift_Mailer $mailer The mailer to use * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param int|string $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ - public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true) + public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, bool $bubble = true) { parent::__construct($level, $bubble); @@ -50,8 +50,8 @@ class SwiftMailerHandler extends MailHandler /** * Creates instance of Swift_Message to be sent * - * @param string $content formatted email body to be sent - * @param array $records Log records that formed the content + * @param string $content formatted email body to be sent + * @param array $records Log records that formed the content * @return Swift_Message */ protected function buildMessage(string $content, array $records): Swift_Message diff --git a/tests/Monolog/Handler/GroupHandlerTest.php b/tests/Monolog/Handler/GroupHandlerTest.php index a466b39b..d0ffdf01 100644 --- a/tests/Monolog/Handler/GroupHandlerTest.php +++ b/tests/Monolog/Handler/GroupHandlerTest.php @@ -92,14 +92,14 @@ class GroupHandlerTest extends TestCase */ public function testHandleBatchUsesProcessors() { - $testHandlers = array(new TestHandler(), new TestHandler()); + $testHandlers = [new TestHandler(), new TestHandler()]; $handler = new GroupHandler($testHandlers); $handler->pushProcessor(function ($record) { $record['extra']['foo'] = true; return $record; }); - $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); + $handler->handleBatch([$this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)]); foreach ($testHandlers as $test) { $this->assertTrue($test->hasDebugRecords()); $this->assertTrue($test->hasInfoRecords()); diff --git a/tests/Monolog/Handler/LogmaticTest.php b/tests/Monolog/Handler/LogmaticHandlerTest.php similarity index 100% rename from tests/Monolog/Handler/LogmaticTest.php rename to tests/Monolog/Handler/LogmaticHandlerTest.php