tomphp/context-logger
Composer 安装命令:
composer require tomphp/context-logger
包简介
A PSR-3 compliant logger decorator which allows context metadata to be built up.
README 文档
README
A PSR-3 compliant logger decorator which allows context metadata to be built up.
Installation
$ composer require tomphp/context-logger
Usage
<?php use Monolog\Logger; use Monolog\Handler\StreamHandler; use TomPHP\ContextLogger; $monolog = new Logger('name'); $monolog->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); $log = new ContextLogger($monolog); $log->addContext('correlation_id', uniqid()); $log->error('There was an error');
Setting the Context
An original context can be set by providing an array as the second argument to the constructor:
$log = new ContextLogger($monolog, ['correlation_id' => uniqid()]);
The context can be added to or modified by the
addContext(string $name, $value) method.
The context can also be added to/modified by providing an array to the
$context parameter of any of the PSR-3 LoggerInterface methods.
Removing Context
You can remove a item from the context by using the removeContext(string $name)
method.
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-20