jd297 / psr-logger
Simple implementation of PSR-3 (Logger Interface)
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.11
- jd297/psr-clock: ^1.0
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5.26
Suggests
- jd297/psr-clock: Implementation according to PSR-20 (Clock) is required
Provides
- psr/log-implementation: 3.0.0
This package is auto-updated.
Last update: 2024-04-09 12:21:33 UTC
README
Simple implementation of PSR-3 (Logger Interface).
Requirements
The following versions of PHP are supported by this version.
- PHP ^8.1
Usage
Handler
All handlers implement the Jd297\Psr\Logger\Handler\HandlerInterface.
FileHandler
The FileHandler logs to a file that is specified in the first argument.
use Jd297\Psr\Logger\Handler\FileHandler; $fileHandler = new FileHandler('[projectdir]/log/dev.log');
Logger
Instantiate a Logger with a Clock that implements Psr\Clock\ClockInterface and an array of handlers that implement Jd297\Psr\Logger\Handler\HandlerInterface.
use Jd297\Psr\Clock\SystemClock; use Jd297\Psr\Logger\Logger; use Psr\Log\LogLevel; $logger = new Logger(new SystemClock(), [$fileHandler]); $logger->log(LogLevel::INFO, 'User "{username}" created with email "{email}".', [ 'username' => 'john', 'email' => 'john.doe@local.local', ]);
Composer
Scripts
Reformat code with PHP CS Fixer.
$ composer reformat
Test source code with PHPUnit.
$ composer unit
Analyse files with PHPStan (Level 9).
$ composer analyse
License
The BSD 2-Clause "Simplified" License (BSD-2-Clause). Please see License File for more information.