From 7bc9c1d8add7e9a5d1304240341f4086a3a7fdd8 Mon Sep 17 00:00:00 2001 From: Nicolas Vanheuverzwijn Date: Fri, 2 Feb 2024 12:30:32 -0500 Subject: [PATCH] chore: fix all code style issues --- src/Monolog/Formatter/LogdnaFormatter.php | 13 ++++++----- src/Monolog/Handler/LogdnaHandler.php | 22 ++++++++++++------- .../Monolog/Formatter/LogdnaFormatterTest.php | 2 -- tests/bootstrap.php | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/Monolog/Formatter/LogdnaFormatter.php b/src/Monolog/Formatter/LogdnaFormatter.php index e54d6e1..0569cb0 100644 --- a/src/Monolog/Formatter/LogdnaFormatter.php +++ b/src/Monolog/Formatter/LogdnaFormatter.php @@ -15,13 +15,15 @@ * Encode records in a json format compatible with Logdna * @author Nicolas Vanheuverzwijn */ -class LogdnaFormatter extends \Monolog\Formatter\JsonFormatter { - - public function __construct(int $batchMode = self::BATCH_MODE_NEWLINES, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = true, bool $includeStacktraces = false) { +class LogdnaFormatter extends \Monolog\Formatter\JsonFormatter +{ + public function __construct(int $batchMode = self::BATCH_MODE_NEWLINES, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = true, bool $includeStacktraces = false) + { parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces); } - protected function normalizeRecord(\Monolog\LogRecord $record): array { + protected function normalizeRecord(\Monolog\LogRecord $record): array + { $date = new \DateTime(); $json = [ @@ -39,7 +41,8 @@ protected function normalizeRecord(\Monolog\LogRecord $record): array { return $this->normalize($json); } - protected function getMetadata(\Monolog\LogRecord $record): array { + protected function getMetadata(\Monolog\LogRecord $record): array + { $meta = $record->context; if ($record->extra) { $meta['monolog_extra'] = $record->extra; diff --git a/src/Monolog/Handler/LogdnaHandler.php b/src/Monolog/Handler/LogdnaHandler.php index c0a2955..5050cdb 100644 --- a/src/Monolog/Handler/LogdnaHandler.php +++ b/src/Monolog/Handler/LogdnaHandler.php @@ -19,8 +19,8 @@ * @see https://docs.logdna.com/docs/api * @author Nicolas Vanheuverzwijn */ -class LogdnaHandler extends \Monolog\Handler\AbstractProcessingHandler { - +class LogdnaHandler extends \Monolog\Handler\AbstractProcessingHandler +{ /** * @var string $ingestion_key */ @@ -54,21 +54,24 @@ class LogdnaHandler extends \Monolog\Handler\AbstractProcessingHandler { /** * @param string $value */ - public function setIP($value) { + public function setIP($value) + { $this->ip = $value; } /** * @param string $value */ - public function setMAC($value) { + public function setMAC($value) + { $this->mac = $value; } /** * @param string $tags */ - public function setTags($tags) { + public function setTags($tags) + { $this->tags = $tags; } @@ -78,7 +81,8 @@ public function setTags($tags) { * @param int $level * @param bool $bubble */ - public function __construct($ingestion_key, $hostname, $level = \Monolog\Logger::DEBUG, bool $bubble = true) { + public function __construct($ingestion_key, $hostname, $level = \Monolog\Logger::DEBUG, bool $bubble = true) + { parent::__construct($level, $bubble); if (!\extension_loaded('curl')) { @@ -93,7 +97,8 @@ public function __construct($ingestion_key, $hostname, $level = \Monolog\Logger: /** * @param \Monolog\LogRecord $record */ - protected function write(\Monolog\LogRecord $record): void { + protected function write(\Monolog\LogRecord $record): void + { $headers = ['Content-Type: application/json']; $data = $record->formatted; @@ -119,7 +124,8 @@ protected function write(\Monolog\LogRecord $record): void { /** * @return \Zwijn\Monolog\Formatter\LogdnaFormatter */ - protected function getDefaultFormatter(): FormatterInterface { + protected function getDefaultFormatter(): FormatterInterface + { return new \Zwijn\Monolog\Formatter\LogdnaFormatter(); } } diff --git a/tests/Monolog/Formatter/LogdnaFormatterTest.php b/tests/Monolog/Formatter/LogdnaFormatterTest.php index 9f3f61b..3c978ba 100644 --- a/tests/Monolog/Formatter/LogdnaFormatterTest.php +++ b/tests/Monolog/Formatter/LogdnaFormatterTest.php @@ -6,7 +6,6 @@ class LogdnaFormatterTest extends TestCase { - /** * @var \Zwijn\Monolog\Formatter\LogdnaFormatter */ @@ -88,5 +87,4 @@ public function testFormatEmptyContextAndExtra(): void $this->assertEquals($decoded_json['lines'][0]['level'], $record->level->toPsrLogLevel()); $this->assertEquals($decoded_json['lines'][0]['meta'], []); } - } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f091c14..d21c14d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,3 @@