\Monolog\HandlerFingersCrossedHandler

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.

Summary

Methods
Properties
Constants
pushProcessor()
popProcessor()
handleBatch()
close()
__destruct()
__sleep()
__construct()
isHandling()
activate()
handle()
reset()
clear()
getHandler()
setFormatter()
getFormatter()
No public properties found
No constants found
processRecord()
resetProcessors()
$processors
$handler
$activationStrategy
$buffering
$bufferSize
$buffer
$stopBuffering
$passthruLevel
$bubble
N/A
flushBuffer()
No private properties found
N/A

Properties

$processors

$processors : callable[]

Type

callable[]

$handler

$handler : callable|\Monolog\Handler\HandlerInterface

Type

HandlerInterface

$activationStrategy

$activationStrategy : \Monolog\Handler\FingersCrossed\ActivationStrategyInterface

Type

ActivationStrategyInterface

$buffering

$buffering : bool

Type

bool

$bufferSize

$bufferSize : int

Type

int

$buffer

$buffer : \Monolog\Handler\Record[]

Type

Record[]

$stopBuffering

$stopBuffering : bool

Type

bool

$passthruLevel

$passthruLevel : ?int

Type

?int

$bubble

$bubble : bool

Type

bool

Methods

pushProcessor()

pushProcessor(callable  $callback) : \Monolog\Handler\HandlerInterface

{@inheritDoc}

Parameters

callable $callback

Returns

\Monolog\Handler\HandlerInterface —

popProcessor()

popProcessor() : callable

{@inheritDoc}

Returns

callable —

handleBatch()

handleBatch(array  $records) : void

Handles a set of records at once.

Parameters

array $records

The records to handle (an array of record arrays)

close()

close() : void

Closes the handler.

__destruct()

__destruct() : mixed

Returns

mixed —

__sleep()

__sleep() : mixed

Returns

mixed —

__construct()

__construct(callable|\Monolog\Handler\HandlerInterface  $handler, int|string|\Monolog\Handler\FingersCrossed\ActivationStrategyInterface  $activationStrategy = null, int  $bufferSize, bool  $bubble = true, bool  $stopBuffering = true, int|string  $passthruLevel = null) : mixed

Parameters

callable|\Monolog\Handler\HandlerInterface $handler

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

int|string|\Monolog\Handler\FingersCrossed\ActivationStrategyInterface $activationStrategy

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

int $bufferSize

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

bool $bubble

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

bool $stopBuffering

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

int|string $passthruLevel

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

Returns

mixed —

isHandling()

isHandling(array  $record) : bool

{@inheritDoc}

Parameters

array $record

Returns

bool —

activate()

activate() : void

Manually activate this logger regardless of the activation strategy

handle()

handle(array  $record) : bool

{@inheritDoc}

Parameters

array $record

Returns

bool —

reset()

reset() : void

clear()

clear() : void

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

It also resets the handler to its initial buffering state.

getHandler()

getHandler(array  $record = null) : \Monolog\Handler\HandlerInterface

Return the nested handler

If the handler was provided as a factory callable, this will trigger the handler's instantiation.

Parameters

array $record

Returns

\Monolog\Handler\HandlerInterface —

setFormatter()

setFormatter(\Monolog\Formatter\FormatterInterface  $formatter) : \Monolog\Handler\HandlerInterface

Sets the formatter.

Parameters

\Monolog\Formatter\FormatterInterface $formatter

Returns

\Monolog\Handler\HandlerInterface —

self

getFormatter()

getFormatter() : \Monolog\Formatter\FormatterInterface

Gets the formatter.

Returns

\Monolog\Formatter\FormatterInterface —

processRecord()

processRecord(array  $record) : array

Processes a record.

Parameters

array $record

Returns

array —

resetProcessors()

resetProcessors() : void

flushBuffer()

flushBuffer() : void

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