\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 : 

Type

$bubble

$bubble : 

Type

$thresholdMap

$thresholdMap : array<mixed,integer>

Type

array<mixed,integer>

$buffer

$buffer : array<mixed,mixed[]>

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

Type

array<mixed,mixed[]>

Methods

__construct()

__construct(\Monolog\Handler\HandlerInterface  $handler, array<mixed,integer>  $thresholdMap = array(), integer|string  $level = \Monolog\Logger::DEBUG, boolean  $bubble = true) 

Parameters

\Monolog\Handler\HandlerInterface $handler
array<mixed,integer> $thresholdMap

Dictionary of logger level => threshold

integer|string $level

The minimum logging level at which this handler will be triggered

boolean $bubble

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

isHandling()

isHandling(array  $record) 

{@inheritdoc}

Parameters

array $record

setLevel()

setLevel(integer|string  $level) : self

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

Parameters

integer|string $level

Level or level name

Returns

self

getLevel()

getLevel() : integer

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

Returns

integer

setBubble()

setBubble(boolean  $bubble) : self

Sets the bubbling behavior.

Parameters

boolean $bubble

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

Returns

self

getBubble()

getBubble() : boolean

Gets the bubbling behavior.

Returns

boolean —

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

reset()

reset() : void

handleBatch()

handleBatch(array  $records) 

Handles a set of records at once.

Parameters

array $records

The records to handle (an array of record arrays)

close()

close() 

Closes the handler.

Ends a log cycle and frees all resources used by the handler.

Closing a Handler means flushing all buffers and freeing any open resources/handles.

Implementations have to be idempotent (i.e. it should be possible to call close several times without breakage) and ideally handlers should be able to reopen themselves on handle() after they have been closed.

This is useful at the end of a request and will be called automatically when the object is destroyed if you extend Monolog\Handler\Handler.

If you are thinking of calling this method yourself, most likely you should be calling ResettableInterface::reset instead. Have a look.

__destruct()

__destruct() 

__sleep()

__sleep() 

handle()

handle(array  $record) : Boolean

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.

Parameters

array $record

The record to handle

Returns

Boolean —

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.