enrise / psr-log-extension
An extension to the Psr\Log package
Installs: 5 085
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 0
Open Issues: 0
Requires
- php: ^5.4
- psr/log: ^1.0
Requires (Dev)
- phpspec/phpspec: ^2.0
This package is not auto-updated.
Last update: 2022-02-01 12:45:33 UTC
README
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.