\Monolog\HandlerOverflowHandler

Handler to only pass log messages when a certain threshold of number of messages is reached.

This can be useful in cases of processing a batch of data, but you're for example only interested in case it fails catastrophically instead of a warning for 1 or 2 events. Worse things can happen, right?

Usage example:

  $log = new Logger('application');
  $handler = new SomeHandler(...)

  // Pass all warnings to the handler when more than 10 & all error messages when more then 5
  $overflow = new OverflowHandler($handler, [Logger::WARNING => 10, Logger::ERROR => 5]);

  $log->pushHandler($overflow);

Summary

Methods
Properties
Constants
__construct()
isHandling()
setLevel()
getLevel()
setBubble()
getBubble()
reset()
handleBatch()
close()
__destruct()
__sleep()
handle()
setFormatter()
getFormatter()
No public properties found
No constants found
No protected methods found
$level
$bubble
N/A
No private methods found
$handler
$thresholdMap
$buffer
N/A

Properties

$level

$level : int

Type

int

$bubble

$bubble : bool

Type

bool

$handler

$handler : \Monolog\Handler\HandlerInterface

Type

HandlerInterface

$thresholdMap

$thresholdMap : int[]

Type

int[]

$buffer

$buffer : array[]

Buffer of all messages passed to the handler before the threshold was reached

Type

array[]

Methods

__construct()

__construct(\Monolog\Handler\HandlerInterface  $handler, int[]  $thresholdMap = [], mixed  $level = Logger::DEBUG, bool  $bubble = true) : mixed

Parameters

\Monolog\Handler\HandlerInterface $handler
int[] $thresholdMap

Dictionary of logger level => threshold

mixed $level

The minimum logging level at which this handler will be triggered

bool $bubble

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

Returns

mixed —

isHandling()

isHandling(array  $record) : bool

{@inheritDoc}

Parameters

array $record

Returns

bool —

setLevel()

setLevel(mixed  $level) : self

Sets minimum logging level at which this handler will be triggered.

Parameters

mixed $level

Returns

self —

getLevel()

getLevel() : int

Gets minimum logging level at which this handler will be triggered.

Returns

int —

setBubble()

setBubble(bool  $bubble) : self

Sets the bubbling behavior.

Parameters

bool $bubble

true means that this handler allows bubbling. false means that bubbling is not permitted.

Returns

self —

getBubble()

getBubble() : bool

Gets the bubbling behavior.

Returns

bool —

true means that this handler allows bubbling. false means that bubbling is not permitted.

reset()

reset() : void

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 —

handle()

handle(array  $record) : bool

Handles a record.

All records may be passed to this method, and the handler should discard those that it does not want to handle.

The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.

{@inheritDoc}

Parameters

array $record

Returns

bool —

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 —