Documentation

FingersCrossedHandler extends Handler
in package
implements ProcessableHandlerInterface, ResettableInterface, FormattableHandlerInterface uses ProcessableHandlerTrait

Buffers all records until a certain level is reached

The advantage of this approach is that you don't get any clutter in your log files. Only requests which actually trigger an error (or whatever your actionLevel is) will be in the logs, but they will contain all records, not only those above the level threshold.

You can then have a passthruLevel as well which means that at the end of the request, even if it did not get activated, it will still send through log records of e.g. at least a warning level.

You can find the various activation strategies in the Monolog\Handler\FingersCrossed\ namespace.

Tags
author

Jordi Boggiano j.boggiano@seld.be

Table of Contents

Interfaces

ProcessableHandlerInterface
Interface to describe loggers that have processors
ResettableInterface
Handler or Processor implementing this interface will be reset when Logger::reset() is called.
FormattableHandlerInterface
Interface to describe loggers that have a formatter

Properties

$activationStrategy  : ActivationStrategyInterface
$bubble  : bool
$buffer  : array<string|int, LogRecord>
$buffering  : bool
$bufferSize  : int
$handler  : Closure|HandlerInterface
Handler or factory Closure($record, $this)
$passthruLevel  : Level|null
$processors  : array<string|int, callable>
$stopBuffering  : bool

Methods

__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
activate()  : void
Manually activate this logger regardless of the activation strategy
clear()  : void
Clears the buffer without flushing any messages down to the wrapped handler.
close()  : void
Closes the handler.
getFormatter()  : FormatterInterface
Gets the formatter.
getHandler()  : HandlerInterface
Return the nested handler
handle()  : bool
Handles a record.
handleBatch()  : void
Handles a set of records at once.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
popProcessor()  : callable
pushProcessor()  : HandlerInterface
reset()  : void
setFormatter()  : HandlerInterface
Sets the formatter.
processRecord()  : LogRecord
resetProcessors()  : void
flushBuffer()  : void
Resets the state of the handler. Stops forwarding records to the wrapped handler.

Properties

$handler

Handler or factory Closure($record, $this)

protected Closure|HandlerInterface $handler
Tags
phpstan-var

(Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<(callable(LogRecord): LogRecord)|ProcessorInterface>

Methods

__construct()

public __construct(Closure|HandlerInterface $handler[, int|string|Level|LogLevel::* $activationStrategy = null ][, int $bufferSize = 0 ][, bool $bubble = true ][, bool $stopBuffering = true ][, int|string|Level|LogLevel::*|null $passthruLevel = null ]) : mixed
Parameters
$handler : Closure|HandlerInterface

Handler or factory Closure($record|null, $fingersCrossedHandler).

$activationStrategy : int|string|Level|LogLevel::* = null

Strategy which determines when this handler takes action, or a level name/value at which the handler is activated

$bufferSize : int = 0

How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.

$bubble : bool = true

Whether the messages that are handled can bubble up the stack or not

$stopBuffering : bool = true

Whether the handler should stop buffering after being triggered (default true)

$passthruLevel : int|string|Level|LogLevel::*|null = null

Minimum level to always flush to handler on close, even if strategy not triggered

Tags
phpstan-param

(Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler

phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::*|ActivationStrategyInterface $activationStrategy

phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $passthruLevel

__destruct()

public __destruct() : mixed

activate()

Manually activate this logger regardless of the activation strategy

public activate() : void

clear()

Clears the buffer without flushing any messages down to the wrapped handler.

public clear() : void

It also resets the handler to its initial buffering state.

handle()

Handles a record.

public handle(LogRecord $record) : bool
Parameters
$record : LogRecord

The record to handle

Tags
inheritDoc
Return values
bool

true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.

handleBatch()

Handles a set of records at once.

public handleBatch(array<string|int, mixed> $records) : void
Parameters
$records : array<string|int, mixed>

The records to handle

Tags
inheritDoc

isHandling()

Checks whether the given record will be handled by this handler.

public isHandling(LogRecord $record) : bool
Parameters
$record : LogRecord

Partial log record having only a level initialized

Tags
inheritDoc
Return values
bool

flushBuffer()

Resets the state of the handler. Stops forwarding records to the wrapped handler.

private flushBuffer() : void

        
On this page

Search results