boerl/zf1-log-psr3

一个包装Zend Framework 1 Logger使其与PSR-3兼容的包装器。

v0.1.1 2016-12-21 14:03 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:20:06 UTC


README

你是否曾经想在现代的松散耦合库中使用你那古老的(时尚的)ZF1 logger,该库期望一个PSR-3兼容的logger?那么这个库就是为你准备的。你可以保留现有的logger(例如,与其他软件组件共享),并伪装它以将其提供给新库。

特性

  • PSR-3样式的占位符被重写为ZF1样式。例如,{example}变为%example%。(可以禁用。)
  • logLevel被添加到extras cq上下文数组中。(可以禁用。)
  • (与这个库的目标不是直接相关的,但可用于测试:)提供了一个非常基本的Zend_Log_Writer_Abstract实现:MemoryWriter。它将格式化的日志消息保留在内存中,以便稍后检索。

使用方法

使用此包composer以及使用其自动加载器

// Start with your existing instance of Zend_Log.
$myZendLog = new \Zend_Log();

// Optionally create a configuration array.
$optionalConfig = ['foo' => 'bar'];

// Instantiate the Wrapper from the existing Zend_Log and optionally the configuration.
$myPsr3CompliantLogger = new \Boerl\Zf1LogPsr3\Wrapper($myZendLog, $optionalConfig);

有关可用配置选项,请参阅Wrapper::getDefaultConfig()

链接