BatchingLogProcessor implements LogProcessor
FinalYes
Batches log records for efficient export.
Collects log records in memory and exports them in batches when:
- The batch size limit is reached
- flush() is explicitly called
- the system is shutting down
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(Exporter $exporter[, int $batchSize = 512 ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : mixed
Parameters
- $exporter : Exporter
- $batchSize : int = 512
- $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
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.