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
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
$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
$processors
protected
array<string|int, callable>
$processors
= []
Tags
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
__destruct()
public
__destruct() : mixed
__sleep()
public
__sleep() : mixed
close()
Closes the handler.
public
close() : void
Tags
getAcceptedLevels()
public
getAcceptedLevels() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getFormatter()
Gets the formatter.
public
getFormatter() : FormatterInterface
Tags
Return values
FormatterInterfacegetHandler()
Return the nested handler
public
getHandler([LogRecord|null $record = null ]) : HandlerInterface
If the handler was provided as a factory, this will trigger the handler's instantiation.
Parameters
- $record : LogRecord|null = null
Return values
HandlerInterfacehandle()
Handles a record.
public
handle(LogRecord $record) : bool
Parameters
- $record : LogRecord
-
The record to handle
Tags
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
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
Return values
boolpopProcessor()
public
popProcessor() : callable
Tags
Return values
callablepushProcessor()
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Tags
Return values
HandlerInterfacereset()
public
reset() : void
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
Return values
$thissetFormatter()
Sets the formatter.
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Tags
Return values
HandlerInterface —self
processRecord()
protected
processRecord(LogRecord $record) : LogRecord
Parameters
- $record : LogRecord
Return values
LogRecordresetProcessors()
protected
resetProcessors() : void