softonic / monolog-request-id-processor
Monolog X-Request-ID processor to add traceability to all logs
Installs: 8 319
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- monolog/monolog: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.4
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
- rector/rector: ^0.11.20
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2022-02-28 10:57:20 UTC
README
Monolog X-Request-ID processor to add traceability to all logs.
Processor based on the official UidProcessor implementation, but using x-request-id
instead of uid
.
Main features
- Add to the extra logs field the x-request-id provided.
Installation
You can require the last version of the package using composer
composer require softonic/monolog-request-id-processor
Configuration
use Monolog\Logger; $requestId = 'fb703a2f-04ac-470c-bc6b-a4d965a7e404'; // Get x-request-id from any source instead of hardcode it. $log = new Monolog\Logger('test'); $log->pushProcessor(new \Softonic\Monolog\Processors\RequestId($requestId)); $log->pushHandler(…); $log->info('Interesting information about the request.');
Testing
softonic/monolog-request-id-processor
has a PHPUnit test suite, and a coding style compliance test suite using PHP CS Fixer.
To run the tests, run the following command from the project folder.
$ make tests
To open a terminal in the dev environment:
$ make debug
License
The Apache 2.0 license. Please see LICENSE for more information.