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
Interfaces, Classes and Traits
- 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
Table of Contents
- $activationStrategy : ActivationStrategyInterface
- $bubble : bool
- $buffer : array<string|int, Record>
- $buffering : bool
- $bufferSize : int
- $handler : callable|HandlerInterface
- $passthruLevel : int|null
- $processors : array<string|int, callable>
- $stopBuffering : bool
- __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
- {@inheritDoc}
- handleBatch() : void
- Handles a set of records at once.
- isHandling() : bool
- {@inheritDoc}
- popProcessor() : callable
- {@inheritDoc}
- pushProcessor() : HandlerInterface
- {@inheritDoc}
- reset() : void
- setFormatter() : HandlerInterface
- Sets the formatter.
- processRecord() : array<string|int, mixed>
- Processes a record.
- resetProcessors() : void
- flushBuffer() : void
- Resets the state of the handler. Stops forwarding records to the wrapped handler.
Properties
$activationStrategy
protected
ActivationStrategyInterface
$activationStrategy
$bubble
protected
bool
$bubble
$buffer
protected
array<string|int, Record>
$buffer
= []
$buffering
protected
bool
$buffering
= true
$bufferSize
protected
int
$bufferSize
$handler
protected
callable|HandlerInterface
$handler
Tags
$passthruLevel
protected
int|null
$passthruLevel
Tags
$processors
protected
array<string|int, callable>
$processors
= []
Tags
$stopBuffering
protected
bool
$stopBuffering
Methods
__construct()
public
__construct(callable|HandlerInterface $handler[, int|string|ActivationStrategyInterface $activationStrategy = null ], int $bufferSize[, bool $bubble = true ][, bool $stopBuffering = true ][, int|string $passthruLevel = null ]) : mixed
Parameters
- $handler : callable|HandlerInterface
-
Handler or factory callable($record|null, $fingersCrossedHandler).
- $activationStrategy : int|string|ActivationStrategyInterface = null
-
Strategy which determines when this handler takes action, or a level name/value at which the handler is activated
- $bufferSize : int
-
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 = null
-
Minimum level to always flush to handler on close, even if strategy not triggered
Tags
Return values
mixed —__destruct()
public
__destruct() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —activate()
Manually activate this logger regardless of the activation strategy
public
activate() : void
Return values
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.
Return values
void —close()
Closes the handler.
public
close() : void
Return values
void —getFormatter()
Gets the formatter.
public
getFormatter() : FormatterInterface
Return values
FormatterInterface —getHandler()
Return the nested handler
public
getHandler([array<string|int, mixed>|null $record = null ]) : HandlerInterface
If the handler was provided as a factory callable, this will trigger the handler's instantiation.
Parameters
- $record : array<string|int, mixed>|null = null
Tags
Return values
HandlerInterface —handle()
{@inheritDoc}
public
handle(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
Return values
bool —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 (an array of record arrays)
Return values
void —isHandling()
{@inheritDoc}
public
isHandling(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
Return values
bool —popProcessor()
{@inheritDoc}
public
popProcessor() : callable
Return values
callable —pushProcessor()
{@inheritDoc}
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Return values
HandlerInterface —reset()
public
reset() : void
Return values
void —setFormatter()
Sets the formatter.
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Return values
HandlerInterface —self
processRecord()
Processes a record.
protected
processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —resetProcessors()
protected
resetProcessors() : void
Return values
void —flushBuffer()
Resets the state of the handler. Stops forwarding records to the wrapped handler.
private
flushBuffer() : void