Monolog processor that stamps request correlation ID onto log records.
// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
<?php
declare(strict_types=1);
namespace App\Monolog;
use App\Observability\RequestIdGenerator;
use Monolog\LogRecord;
use Monolog\Processor\ProcessorInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Stamps the current request's correlation id onto every log record's `extra`.
*
* Reads the id that {@see \App\EventSubscriber\RequestIdSubscriber} placed on
* the request attributes. On CLI / worker runs there is no main request, so the
* id is simply absent — the record is still emitted, just without correlation.
*/
final readonly class RequestIdProcessor implem
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key