ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\HandlerWrapper Class Reference

This simple wrapper class can be used to extend handlers functionality. More...

+ Inheritance diagram for Monolog\Handler\HandlerWrapper:
+ Collaboration diagram for Monolog\Handler\HandlerWrapper:

Public Member Functions

 __construct (HandlerInterface $handler)
 HandlerWrapper constructor. More...
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
bool
} More...
 
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
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.
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 reset ()
 

Protected Attributes

 $handler
 

Detailed Description

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); }

Author
Alexey Karapetov alexe.nosp@m.y@ka.nosp@m.rapet.nosp@m.ov.c.nosp@m.om

Definition at line 34 of file HandlerWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\HandlerWrapper::__construct ( HandlerInterface  $handler)

HandlerWrapper constructor.

Parameters
HandlerInterface$handler

Definition at line 45 of file HandlerWrapper.php.

References Monolog\Handler\HandlerWrapper\$handler.

46  {
47  $this->handler = $handler;
48  }

Member Function Documentation

◆ getFormatter()

Monolog\Handler\HandlerWrapper::getFormatter ( )

{Gets the formatter.

Returns
FormatterInterface
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 105 of file HandlerWrapper.php.

106  {
107  return $this->handler->getFormatter();
108  }

◆ handle()

Monolog\Handler\HandlerWrapper::handle ( array  $record)

{Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.

Parameters
array$recordThe record to handle
Returns
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.
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 61 of file HandlerWrapper.php.

62  {
63  return $this->handler->handle($record);
64  }

◆ handleBatch()

Monolog\Handler\HandlerWrapper::handleBatch ( array  $records)

{Handles a set of records at once.

Parameters
array$recordsThe records to handle (an array of record arrays)
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 69 of file HandlerWrapper.php.

70  {
71  return $this->handler->handleBatch($records);
72  }
$records
Definition: simple_test.php:22

◆ isHandling()

Monolog\Handler\HandlerWrapper::isHandling ( array  $record)

{Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.

Parameters
array$recordPartial log record containing only a level key
Returns
bool
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 53 of file HandlerWrapper.php.

54  {
55  return $this->handler->isHandling($record);
56  }

◆ popProcessor()

Monolog\Handler\HandlerWrapper::popProcessor ( )

{Removes the processor on top of the stack and returns it.

Returns
callable
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 87 of file HandlerWrapper.php.

88  {
89  return $this->handler->popProcessor();
90  }

◆ pushProcessor()

Monolog\Handler\HandlerWrapper::pushProcessor (   $callback)

{Adds a processor in the stack.

Parameters
callable$callback
Returns
self
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 77 of file HandlerWrapper.php.

78  {
79  $this->handler->pushProcessor($callback);
80 
81  return $this;
82  }

◆ reset()

Monolog\Handler\HandlerWrapper::reset ( )

Implements Monolog\ResettableInterface.

Definition at line 110 of file HandlerWrapper.php.

111  {
112  if ($this->handler instanceof ResettableInterface) {
113  return $this->handler->reset();
114  }
115  }

◆ setFormatter()

Monolog\Handler\HandlerWrapper::setFormatter ( FormatterInterface  $formatter)

{Sets the formatter.

Parameters
FormatterInterface$formatter
Returns
self
}

Implements Monolog\Handler\HandlerInterface.

Definition at line 95 of file HandlerWrapper.php.

96  {
97  $this->handler->setFormatter($formatter);
98 
99  return $this;
100  }

Field Documentation

◆ $handler

Monolog\Handler\HandlerWrapper::$handler
protected

Definition at line 39 of file HandlerWrapper.php.

Referenced by Monolog\Handler\HandlerWrapper\__construct().


The documentation for this class was generated from the following file: