Skip to content

Commit

Permalink
Linted code
Browse files Browse the repository at this point in the history
  • Loading branch information
8ctopus committed Mar 20, 2023
1 parent 71570a9 commit 80b2138
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions demo.php
@@ -1,28 +1,28 @@
<?php

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

$console = (new Apix\Log\Logger\Stream('php://stdout'))
->setFormat(new Apix\Log\Format\ConsoleColors())
->setMinLevel('debug');
->setFormat(new Apix\Log\Format\ConsoleColors())
->setMinLevel('debug');

$file = (new Apix\Log\Logger\File(__DIR__ . '/app.log'))
// intercept logs that are >= `warning`
->setMinLevel('warning')
->setMinLevel('warning')
// don't propagate to further buckets
->setCascading(false)
->setCascading(false)
// postpone writing logs to file
->setDeferred(true)
->setDeferred(true)
// flush logs to file once 100 logs are collected
->setDeferredTrigger(100);
->setDeferredTrigger(100);

$logger = new Apix\Log\Logger([$console, $file]);

$logger->debug('App started');

$logger->notice('Running out of {items} - left {left}', [
'items' => 'beers',
'left' => 5,
'items' => 'beers',
'left' => 5,
]);

$exception = new \Exception('Boo!');
Expand Down
9 changes: 5 additions & 4 deletions src/LogEntry.php
Expand Up @@ -12,6 +12,7 @@

use Apix\Log\Format\FormatInterface;
use Apix\Log\Format\Standard;
use InvalidArgumentException;

/**
* Describes a log Entry.
Expand All @@ -35,9 +36,9 @@ class LogEntry
/**
* Constructor.
*
* @param mixed $level error level
* @param string $message message
* @param mixed[] $context context
* @param mixed $level error level
* @param string $message message
* @param mixed[] $context context
* @param FormatInterface $format the formatter
*/
public function __construct(mixed $level, string $message, array $context = [], ?FormatInterface $format = null)
Expand All @@ -51,7 +52,7 @@ public function __construct(mixed $level, string $message, array $context = [],
$this->name = Logger::getLevelName($level);
$this->levelCode = $level;
} else {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid level', \gettype($level)));
throw new InvalidArgumentException(sprintf('"%s" is not a valid level', \gettype($level)));
}

$this->message = $message;
Expand Down
2 changes: 1 addition & 1 deletion src/Logger.php
Expand Up @@ -142,7 +142,7 @@ public function getBuckets() : array
/**
* Write entry to log
*
* @param LogEntry|array <LogEntry> $log
* @param array <LogEntry>|LogEntry $log
*
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/LoggerInterface.php
Expand Up @@ -38,7 +38,7 @@ interface LoggerInterface
/**
* Write entry to log
*
* @param LogEntry|array <LogEntry> $log
* @param array <LogEntry>|LogEntry $log
*
* @return bool
*/
Expand Down
1 change: 0 additions & 1 deletion src/Logger/Runtime.php
Expand Up @@ -10,7 +10,6 @@

namespace Apix\Log\Logger;

use Apix\Log\Format\Standard;
use Apix\Log\LogEntry;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/Stream.php
Expand Up @@ -63,7 +63,7 @@ public function write(LogEntry|array $log) : bool
throw new LogicException('The stream resource has been destructed too early');
}

if (!is_array($log)) {
if (!is_array($log)) {
$log = [$log];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/LoggerTest.php
Expand Up @@ -11,8 +11,8 @@
namespace Apix\Log\tests;

use Apix\Log\ApixLogException;
use Apix\Log\Logger;
use Apix\Log\LogEntry;
use Apix\Log\Logger;
use Apix\Log\Logger\Stream;
use Psr\Log\InvalidArgumentException;
use Psr\Log\LogLevel;
Expand Down

0 comments on commit 80b2138

Please sign in to comment.