CompositeLogProcessor implements LogProcessor
Read onlyYes
FinalYes
Forwards log records to multiple processors.
This is useful when you need to:
- Send logs to multiple backends (e.g., both console and OTLP)
- Combine batching with memory storage for testing
- Add custom processing alongside export
Interfaces
- LogProcessor
- Interface for processing log records.
Methods
- __construct() : mixed
- flush() : bool
- Export all pending log records.
- process() : void
- Process a log entry.
- processors() : array<string|int, LogProcessor>
- Get all processors in this composite.
- shutdown() : void
- Shutdown the processor.
Methods
__construct()
public
__construct(array<string|int, LogProcessor> $processors[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : mixed
Parameters
- $processors : array<string|int, LogProcessor>
- $errorHandler : ErrorHandler = new ErrorLogHandler()
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
processors()
Get all processors in this composite.
public
processors() : array<string|int, LogProcessor>
Return values
array<string|int, LogProcessor>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.