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
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
$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
$processors
protected
array<string|int, callable>
$processors
= []
Tags
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
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
Return values
array<string|int, mixed> —getFormatter()
Gets the formatter.
public
getFormatter() : FormatterInterface
Return values
FormatterInterface —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
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 —popProcessor()
{@inheritDoc}
public
popProcessor() : callable
Return values
callable —pushProcessor()
{@inheritDoc}
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Return values
HandlerInterface —reset()
public
reset() : void
Return values
void —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
Return values
self —setFormatter()
Sets the formatter.
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Return values
HandlerInterface —self
processRecord()
Processes a record.
protected
processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —resetProcessors()
protected
resetProcessors() : void