innmind / logger
Logger
2.1.0
2021-02-20 10:55 UTC
Requires
- php: ~7.4|~8.0
- innmind/url: ~3.0
- monolog/monolog: ~2.0
- psr/log: ^1.0
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.0
- innmind/coding-standard: ^1.1
- php-http/guzzle7-adapter: ^0.1
- phpunit/phpunit: ~9.0
- sentry/sentry: ~3.1
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2024-12-20 19:44:02 UTC
README
Simple abstraction of monolog to simplify (hopefully) the creation of a logger.
Installation
composer require innmind/logger
Usage
use function Innmind\Logger\bootstrap; use Innmind\Url\Url; $logger = bootstrap( 'myApp', Url::of('file://'.__DIR__.'/var/log.txt'), Url::of('sentry://user@sentry.io/project-id'), ); $concrete = $logger(); $fingersCrossed = $logger('error');
In this example both $concrete
and $fingersCrossed
are instances of Psr\Log\LoggerInterface
with the first one that will write each log to the specified file and to sentry, the latter will only write logs when the error
level is reached.
If you want to specify the log level for each handler you can do it by adding the level
query parameter in the handler url.