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

Table of Contents

Interfaces

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

Properties

$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>

Methods

__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
Handles a record.
handleBatch()  : void
Handles a set of records at once.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
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

__destruct()

public __destruct() : mixed

close()

Closes the handler.

public close() : 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()

Handles a record.

public handle(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

The record to handle

Return values
bool

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.

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)

isHandling()

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

public isHandling(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

Partial log record containing only a level key

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>

        
On this page

Search results