enrise/psr-log-extension

This package is abandoned and no longer maintained. No replacement package was suggested.

An extension to the Psr\Log package

1.0.1 2015-03-16 07:50 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:45:33 UTC


README

Latest Stable Version License

This repository contains an extension on the LoggerAwareTrait that comes with the Psr\Log package. It contains convenience methods to use the LoggerAwareInterface implementation in a safe way. Meaning you don't have to care whether the class you're implementing actually has a logger instance attached to it.

Usage example

The example below works whether a logger instance has been attached or not.

use Psr\Log\LoggerAwareInterface;
use Enrise\Log\LoggerAwareTrait;

class Foo implements LoggerAwareInterface
{
    use LoggerAwareTrait;

    function bar()
    {
        $this->logDebug('Write a debug statement to the log');
    }
}

$foo = new Foo();
$foo->bar(); // All fine

$foo->setLogger(new ConcreteLogger());
$foo->bar(); // Writes to the logger as usual

Credits

License

The MIT License (MIT). Please see License File for more information.