Flow PHP

LogProcessor

Interface for processing log records.

Implementations may collect logs for batching, export them immediately, filter by severity, or perform other processing like enrichment.

Example implementation:

final class BatchingLogProcessor implements LogProcessor
{
    private array $buffer = [];

    public function process(LogEntry $entry): void {
        $this->buffer[] = $entry;
        if (count($this->buffer) >= 100) {
            $this->flush();
        }
    }
    // ...
}

Methods

exporter()  : LogExporter
Get the exporter used by this processor.
flush()  : bool
Export all pending log records.
process()  : void
Process a log entry.

Methods

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


        
On this page

Search results