HandlerWrapper
in package
implements
HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface
This simple wrapper class can be used to extend handlers functionality.
Example: A custom filtering that can be applied to any handler.
Inherit from this class and override handle() like this:
public function handle(array $record) { if ($record meets certain conditions) { return false; } return $this->handler->handle($record); }
Tags
Interfaces, Classes and Traits
- HandlerInterface
- Interface that all Monolog Handlers must implement
- ProcessableHandlerInterface
- Interface to describe loggers that have processors
- FormattableHandlerInterface
- Interface to describe loggers that have a formatter
- ResettableInterface
- Handler or Processor implementing this interface will be reset when Logger::reset() is called.
Table of Contents
- $handler : HandlerInterface
- __construct() : mixed
- close() : void
- Closes the handler.
- getFormatter() : FormatterInterface
- Gets the formatter.
- 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|ProcessorInterface
- Removes the processor on top of the stack and returns it.
- pushProcessor() : HandlerInterface
- Adds a processor in the stack.
- reset() : void
- setFormatter() : HandlerInterface
- Sets the formatter.
Properties
$handler
protected
HandlerInterface
$handler
Methods
__construct()
public
__construct(HandlerInterface $handler) : mixed
Parameters
- $handler : HandlerInterface
Return values
mixed —close()
Closes the handler.
public
close() : void
Return values
void —getFormatter()
Gets the formatter.
public
getFormatter() : FormatterInterface
Return values
FormatterInterface —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)
Return values
void —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 —popProcessor()
Removes the processor on top of the stack and returns it.
public
popProcessor() : callable|ProcessorInterface
Return values
callable|ProcessorInterface —pushProcessor()
Adds a processor in the stack.
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Return values
HandlerInterface —self
reset()
public
reset() : void
Return values
void —setFormatter()
Sets the formatter.
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Return values
HandlerInterface —self