enrise/psr-log-extension

此软件包已被弃用且不再维护。没有推荐替代包。

Psr\Log 软件包的扩展

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

此仓库包含对 LoggerAwareTrait 的扩展,该扩展随 Psr\Log 包提供。它包含了一些方便的方法来安全地使用 LoggerAwareInterface 实现。这意味着你不必担心你正在实现的类是否实际上连接了一个日志实例。

使用示例

以下示例无论是否已连接日志实例都能正常工作。

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

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 获取更多信息。