PipelineLogProcessor implements LogProcessor
Runs a log entry through an ordered chain of {@see LogMiddleware} and forwards the survivors to a single {@see LogSink}.
Each middleware may enrich the entry (returning a new one) or drop it (returning null); a drop short-circuits the chain so later middleware and the sink never see it. The pipeline owns no buffer of its own - self::flush() and self::shutdown() delegate to the sink, since middleware are stateless.
This models the OpenTelemetry LogRecordProcessor pipeline: processors registered in order, each able to modify the record, with mutations visible to the next.
Interfaces
- LogProcessor
- Interface for processing log records.
Methods
- __construct() : mixed
- flush() : bool
- Export all pending log records.
- process() : void
- Process a log entry.
- shutdown() : void
- Shutdown the processor.
Methods
__construct()
public
__construct(array<int, LogMiddleware> $middleware, LogSink $sink) : mixed
Parameters
- $middleware : array<int, LogMiddleware>
-
run in order; the first to return null drops the entry
- $sink : LogSink
flush()
Export all pending log records.
public
flush() : bool
Forces immediate export of any buffered log records.
Return values
bool —True if all records were successfully exported
process()
Process a log entry.
public
process(LogEntry $entry) : void
This is invoked synchronously when a log is emitted. The processor may buffer the entry, export it immediately, or discard it based on filtering rules.
Parameters
- $entry : LogEntry
-
The complete log entry to process
shutdown()
Shutdown the processor.
public
shutdown() : void
Implementations SHOULD flush() pending data before delegating shutdown to the underlying exporter. MUST be idempotent and MUST NOT throw.