innmind/logger

2.1.0 2021-02-20 10:55 UTC

This package is auto-updated.

Last update: 2024-03-20 17:40:58 UTC


README

codecov Build Status Type Coverage

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.