oat-sa/lib-correlation-ids-monolog
Composer 安装命令:
composer require oat-sa/lib-correlation-ids-monolog
包简介
OAT Correlation Ids Monolog Library
README 文档
README
PHP library for correlation ids monolog processor based on the correlation ids library.
Table of contents
Installation
$ composer require oat-sa/lib-correlation-ids-monolog
Principles
This library provides a ready to use monolog processor that will extend the logs context with the correlation ids fetched from the correlation ids registry.
Usage
You need to push the CorrelationIdsMonologProcessor to your logger as follow:
<?php declare(strict_types=1); use OAT\Library\CorrelationIds\Registry\CorrelationIdsRegistry; use OAT\Library\CorrelationIds\Registry\CorrelationIdsRegistryInterface; use OAT\Library\CorrelationIdsMonolog\Processor\CorrelationIdsMonologProcessor; use Monolog\Logger; /** @var CorrelationIdsRegistryInterface $registry */ $registry = new CorrelationIdsRegistry(...); $logger = new Logger('channel-name'); $logger->pushProcessor(new CorrelationIdsMonologProcessor($registry)); ... $logger->info('log message'); // this log entry context will be automatically populated with the correlation ids.
Note: you can customize the log context key names by providing you own CorrelationIdsHeaderNamesProviderInterface implementation and pass it to the CorrelationIdsMonologProcessor constructor.
Tests
To run tests:
$ vendor/bin/phpunit
Note: see phpunit.xml.dist for available test suites.
统计信息
- 总下载量: 576
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-only
- 更新时间: 2019-11-22