0.1 2017-07-08 11:48 UTC

This package is auto-updated.

Last update: 2024-02-20 23:45:49 UTC


Latest Stable Version Total Downloads Build Status Scrutinizer Quality Score

Simple trait that makes any class able to use PSR-3 loggers.


composer require arrilot/logs


use Arrilot\Logs\Logs;

class Foo
    use Logs;

    function bar()
        $this->logger()->error('Error happened in bar!);
        $this->logger()->warning('Warning happened in bar!);
        // etc

$foo = new Foo();
$foo->bar(); // Everything is ok, but nothing was logged anywhere because no logger was set.

$foo->bar(); // There is a log record in $anyPsr3LoggerHere now.

$foo->bar(); // An error and a warning are echo'ed to a screen.

// If you are using Monolog\Registry to store loggers, you can simply pass a logger name and the package will grab a logger from the Registry.
$foo->bar(); // There is a record in application log.

You can also use Arrilot\Logs\EchoLogger as a separate PSR-3 logger without a trait.