\Monolog\HandlerDeduplicationHandler

Simple handler wrapper that deduplicates log records across multiple requests

It also includes the BufferHandler functionality and will buffer all messages until the end of the request or flush() is called.

This works by storing all log records' messages above $deduplicationLevel to the file specified by $deduplicationStore. When further logs come in at the end of the request (or when flush() is called), all those above $deduplicationLevel are checked against the existing stored logs. If they match and the timestamps in the stored log is not older than $time seconds, the new log record is discarded. If no log record is new, the whole data set is discarded.

This is mainly useful in combination with Mail handlers or things like Slack or HipChat handlers that send messages to people, to avoid spamming with the same message over and over in case of a major component failure like a database server being down which makes all requests fail in the same way.

Summary

Methods
Properties
Constants
__construct()
handle()
flush()
__destruct()
close()
clear()
isHandling()
handleBatch()
pushProcessor()
popProcessor()
setFormatter()
getFormatter()
setLevel()
getLevel()
setBubble()
getBubble()
No public properties found
No constants found
getDefaultFormatter()
$handler
$bufferSize
$bufferLimit
$flushOnOverflow
$buffer
$initialized
$level
$bubble
$formatter
$processors
$deduplicationStore
$deduplicationLevel
$time
N/A
isDuplicate()
collectLogs()
appendRecord()
$gc
N/A

Properties

$handler

$handler : 

Type

$bufferSize

$bufferSize : 

Type

$bufferLimit

$bufferLimit : 

Type

$flushOnOverflow

$flushOnOverflow : 

Type

$buffer

$buffer : 

Type

$initialized

$initialized : 

Type

$level

$level : 

Type

$bubble

$bubble : 

Type

$processors

$processors : 

Type

$deduplicationStore

$deduplicationStore : string

Type

string

$deduplicationLevel

$deduplicationLevel : integer

Type

integer

$time

$time : integer

Type

integer

$gc

$gc : boolean

Type

boolean

Methods

__construct()

__construct(\Monolog\Handler\HandlerInterface  $handler, string  $deduplicationStore = null, integer  $deduplicationLevel = \Monolog\Logger::ERROR, integer  $time = 60, Boolean  $bubble = true) 

Parameters

\Monolog\Handler\HandlerInterface $handler

Handler.

string $deduplicationStore

The file/path where the deduplication log should be kept

integer $deduplicationLevel

The minimum logging level for log records to be looked at for deduplication purposes

integer $time

The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through

Boolean $bubble

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

handle()

handle(array  $record) 

{@inheritdoc}

Parameters

array $record

flush()

flush() 

__destruct()

__destruct() 

close()

close() 

Closes the handler.

This will be called automatically when the object is destroyed

clear()

clear() 

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

isHandling()

isHandling(array  $record) : Boolean

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

This is mostly done for performance reasons, to avoid calling processors for nothing.

Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.

Parameters

array $record

Partial log record containing only a level key

Returns

Boolean

handleBatch()

handleBatch(array  $records) 

Handles a set of records at once.

Parameters

array $records

The records to handle (an array of record arrays)

pushProcessor()

pushProcessor(callable  $callback) : self

Adds a processor in the stack.

Parameters

callable $callback

Returns

self

popProcessor()

popProcessor() : callable

Removes the processor on top of the stack and returns it.

Returns

callable

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.

isDuplicate()

isDuplicate(array  $record) 

Parameters

array $record

collectLogs()

collectLogs() 

appendRecord()

appendRecord(array  $record) 

Parameters

array $record