Skip to content

Commit

Permalink
chore: fix all code style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nvanheuverzwijn committed Feb 2, 2024
1 parent c71fc6d commit 7bc9c1d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
13 changes: 8 additions & 5 deletions src/Monolog/Formatter/LogdnaFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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;
Expand Down
22 changes: 14 additions & 8 deletions src/Monolog/Handler/LogdnaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}

Expand All @@ -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')) {
Expand All @@ -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;

Expand All @@ -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();
}
}
2 changes: 0 additions & 2 deletions tests/Monolog/Formatter/LogdnaFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class LogdnaFormatterTest extends TestCase
{

/**
* @var \Zwijn\Monolog\Formatter\LogdnaFormatter
*/
Expand Down Expand Up @@ -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'], []);
}

}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

0 comments on commit 7bc9c1d

Please sign in to comment.