Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jd297/psr-logger
Simple implementation of PSR-3 (Logger Interface)
https://github.com/jd297/psr-logger
logger logging psr psr-3
Last synced: 28 days ago
JSON representation
Simple implementation of PSR-3 (Logger Interface)
- Host: GitHub
- URL: https://github.com/jd297/psr-logger
- Owner: JD297
- License: bsd-2-clause
- Created: 2024-02-06T00:07:24.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-02-09T11:55:01.000Z (11 months ago)
- Last Synced: 2024-04-10T12:20:22.691Z (9 months ago)
- Topics: logger, logging, psr, psr-3
- Language: PHP
- Homepage: https://packagist.org/packages/jd297/psr-logger
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# psr-logger (PSR-3)
Simple implementation of [PSR-3 (Logger Interface)](https://www.php-fig.org/psr/psr-3/).
## 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.
```php
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_.
```php
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' => '[email protected]',
]);
```## Composer
### Scripts
Reformat code with [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer).
``` bash
$ composer reformat
```Test source code with [PHPUnit](https://github.com/sebastianbergmann/phpunit).
``` bash
$ composer unit
```Analyse files with [PHPStan](https://github.com/phpstan/phpstan) (Level 9).
``` bash
$ composer analyse
```## License
The BSD 2-Clause "Simplified" License (BSD-2-Clause). Please see [License File](https://github.com/jd297/psr-logger/blob/master/LICENSE) for more information.