Documentation

FilterHandler extends Handler
in package
implements ProcessableHandlerInterface, ResettableInterface, FormattableHandlerInterface Uses ProcessableHandlerTrait

Simple handler wrapper that filters records based on a list of levels

It can be configured with an exact list of levels to allow, or a min/max level.

Tags
author

Hennadiy Verkh

author

Jordi Boggiano j.boggiano@seld.be

phpstan-import-type

Record from \Monolog\Logger

phpstan-import-type

Level from \Monolog\Logger

phpstan-import-type

LevelName from \Monolog\Logger

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

$acceptedLevels  : array<string|int, int>
Minimum level for logs that are passed to handler
$bubble  : bool
Whether the messages that are handled can bubble up the stack or not
$handler  : callable|HandlerInterface
Handler or factory callable($record, $this)
$processors  : array<string|int, callable>
__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
close()  : void
Closes the handler.
getAcceptedLevels()  : array<string|int, mixed>
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
setAcceptedLevels()  : self
setFormatter()  : HandlerInterface
Sets the formatter.
processRecord()  : array<string|int, mixed>
Processes a record.
resetProcessors()  : void

Properties

$acceptedLevels

Minimum level for logs that are passed to handler

protected array<string|int, int> $acceptedLevels
Tags
phpstan-var

array<Level, int>

$bubble

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

protected bool $bubble

$handler

Handler or factory callable($record, $this)

protected callable|HandlerInterface $handler
Tags
phpstan-var

callable(?Record, HandlerInterface): HandlerInterface|HandlerInterface

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<ProcessorInterface|callable(Record): Record>

Methods

__construct()

public __construct(callable|HandlerInterface $handler[, int|array<string|int, mixed> $minLevelOrList = Logger::DEBUG ][, int|string $maxLevel = Logger::EMERGENCY ][, bool $bubble = true ]) : mixed
Parameters
$handler : callable|HandlerInterface

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

$minLevelOrList : int|array<string|int, mixed> = Logger::DEBUG

A list of levels to accept or a minimum level if maxLevel is provided

$maxLevel : int|string = Logger::EMERGENCY

Maximum level to accept, only used if $minLevelOrList is not an array

$bubble : bool = true

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

Tags
psalm-param

HandlerInterface|callable(?Record, HandlerInterface): HandlerInterface $handler

phpstan-param

Level|LevelName|LogLevel::|array<Level|LevelName|LogLevel::> $minLevelOrList

phpstan-param

Level|LevelName|LogLevel::* $maxLevel

Return values
mixed

__destruct()

public __destruct() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

close()

Closes the handler.

public close() : void
Return values
void

getAcceptedLevels()

public getAcceptedLevels() : array<string|int, mixed>
Tags
phpstan-return

array<int, Level>

Return values
array<string|int, mixed>

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
phpstan-param

Record $record

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

setAcceptedLevels()

public setAcceptedLevels([int|string|array<string|int, mixed> $minLevelOrList = Logger::DEBUG ][, int|string $maxLevel = Logger::EMERGENCY ]) : self
Parameters
$minLevelOrList : int|string|array<string|int, mixed> = Logger::DEBUG

A list of levels to accept or a minimum level or level name if maxLevel is provided

$maxLevel : int|string = Logger::EMERGENCY

Maximum level or level name to accept, only used if $minLevelOrList is not an array

Tags
phpstan-param

Level|LevelName|LogLevel::|array<Level|LevelName|LogLevel::> $minLevelOrList

phpstan-param

Level|LevelName|LogLevel::* $maxLevel

Return values
self

processRecord()

Processes a record.

protected processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Tags
phpstan-param

Record $record

phpstan-return

Record

Return values
array<string|int, mixed>

Search results