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

Jordi Boggiano j.boggiano@seld.be

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, bool>
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  : Closure|HandlerInterface
Handler or factory Closure($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
pushProcessor()  : HandlerInterface
reset()  : void
setAcceptedLevels()  : $this
setFormatter()  : HandlerInterface
Sets the formatter.
processRecord()  : LogRecord
resetProcessors()  : void

Properties

$acceptedLevels

Minimum level for logs that are passed to handler

protected array<string|int, bool> $acceptedLevels

Map of Level value => true

Tags
phpstan-var

array<value-ofLevel::VALUES, true>

$bubble

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

protected bool $bubble

$handler

Handler or factory Closure($record, $this)

protected Closure|HandlerInterface $handler
Tags
phpstan-var

(Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface

$processors

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

array<(callable(LogRecord): LogRecord)|ProcessorInterface>

Methods

__construct()

public __construct(Closure|HandlerInterface $handler[, int|string|Level|array<string|int, int|string|Level|LogLevel::*> $minLevelOrList = Level::Debug ][, int|string|Level|LogLevel::* $maxLevel = Level::Emergency ][, bool $bubble = true ]) : mixed
Parameters
$handler : Closure|HandlerInterface

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

$minLevelOrList : int|string|Level|array<string|int, int|string|Level|LogLevel::*> = Level::Debug

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

$maxLevel : int|string|Level|LogLevel::* = Level::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
phpstan-param

(Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::|array<value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::> $minLevelOrList

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $maxLevel

__destruct()

public __destruct() : mixed

close()

Closes the handler.

public close() : void
Tags
inheritDoc

getAcceptedLevels()

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

list<Level> List of levels

Return values
array<string|int, mixed>

handle()

Handles a record.

public handle(LogRecord $record) : bool
Parameters
$record : LogRecord

The record to handle

Tags
inheritDoc
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

Tags
inheritDoc

isHandling()

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

public isHandling(LogRecord $record) : bool
Parameters
$record : LogRecord

Partial log record having only a level initialized

Tags
inheritDoc
Return values
bool

setAcceptedLevels()

public setAcceptedLevels([int|string|Level|LogLevel::*|array<string|int, int|string|Level|LogLevel::*> $minLevelOrList = Level::Debug ][, int|string|Level|LogLevel::* $maxLevel = Level::Emergency ]) : $this
Parameters
$minLevelOrList : int|string|Level|LogLevel::*|array<string|int, int|string|Level|LogLevel::*> = Level::Debug

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

$maxLevel : int|string|Level|LogLevel::* = Level::Emergency

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

Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::|array<value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::> $minLevelOrList

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $maxLevel

Return values
$this
On this page

Search results