ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
GroupHandler.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Handler;
13 
16 
23 {
24  protected $handlers;
25 
30  public function __construct(array $handlers, $bubble = true)
31  {
32  foreach ($handlers as $handler) {
33  if (!$handler instanceof HandlerInterface) {
34  throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.');
35  }
36  }
37 
38  $this->handlers = $handlers;
39  $this->bubble = $bubble;
40  }
41 
45  public function isHandling(array $record)
46  {
47  foreach ($this->handlers as $handler) {
48  if ($handler->isHandling($record)) {
49  return true;
50  }
51  }
52 
53  return false;
54  }
55 
59  public function handle(array $record)
60  {
61  if ($this->processors) {
62  foreach ($this->processors as $processor) {
63  $record = call_user_func($processor, $record);
64  }
65  }
66 
67  foreach ($this->handlers as $handler) {
68  $handler->handle($record);
69  }
70 
71  return false === $this->bubble;
72  }
73 
77  public function handleBatch(array $records)
78  {
79  if ($this->processors) {
80  $processed = array();
81  foreach ($records as $record) {
82  foreach ($this->processors as $processor) {
83  $processed[] = call_user_func($processor, $record);
84  }
85  }
86  $records = $processed;
87  }
88 
89  foreach ($this->handlers as $handler) {
90  $handler->handleBatch($records);
91  }
92  }
93 
94  public function reset()
95  {
96  parent::reset();
97 
98  foreach ($this->handlers as $handler) {
99  if ($handler instanceof ResettableInterface) {
100  $handler->reset();
101  }
102  }
103  }
104 
109  {
110  foreach ($this->handlers as $handler) {
111  $handler->setFormatter($formatter);
112  }
113 
114  return $this;
115  }
116 }
Base Handler class providing the Handler structure.
__construct(array $handlers, $bubble=true)
Handler or Processor implementing this interface will be reset when Logger::reset() is called...
handle(array $record)
{Handles a record.All records may be passed to this method, and the handler should discard those that...
$records
Definition: simple_test.php:22
Forwards records to multiple handlers.
setFormatter(FormatterInterface $formatter)
{Sets the formatter.self}
isHandling(array $record)
{Checks whether the given record will be handled by this handler.This is mostly done for performance ...
Interface that all Monolog Handlers must implement.
$handler
handleBatch(array $records)
{Handles a set of records at once.The records to handle (an array of record arrays)} ...