\Monolog\HandlerSamplingHandler

Sampling handler

A sampled event stream can be useful for logging high frequency events in a production environment where you only need an idea of what is happening and are not concerned with capturing every occurrence. Since the decision to handle or not handle a particular event is determined randomly, the resulting sampled log is not guaranteed to contain 1/N of the events that occurred in the application, but based on the Law of large numbers, it will tend to be close to this ratio with a large number of attempts.

Summary

Methods
Properties
Constants
pushProcessor()
popProcessor()
__construct()
isHandling()
setLevel()
getLevel()
setBubble()
getBubble()
reset()
handleBatch()
close()
__destruct()
__sleep()
handle()
getHandler()
setFormatter()
getFormatter()
No public properties found
No constants found
processRecord()
resetProcessors()
$processors
$level
$bubble
$handler
$factor
N/A
No private methods found
No private properties found
N/A

Properties

$processors

$processors : callable[]

Type

callable[]

$level

$level : int

Type

int

$bubble

$bubble : bool

Type

bool

$factor

$factor : int

Type

int

Methods

pushProcessor()

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

{@inheritDoc}

Parameters

callable $callback

Returns

\Monolog\Handler\HandlerInterface —

popProcessor()

popProcessor() : callable

{@inheritDoc}

Returns

callable —

__construct()

__construct(callable|\Monolog\Handler\HandlerInterface  $handler, int  $factor) : mixed

Parameters

callable|\Monolog\Handler\HandlerInterface $handler

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

int $factor

Sample factor (e.g. 10 means every ~10th record is sampled)

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

Parameters

array $record

Returns

bool —

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