ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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 
15 
22 {
23  protected $handlers;
24 
29  public function __construct(array $handlers, $bubble = true)
30  {
31  foreach ($handlers as $handler) {
32  if (!$handler instanceof HandlerInterface) {
33  throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.');
34  }
35  }
36 
37  $this->handlers = $handlers;
38  $this->bubble = $bubble;
39  }
40 
44  public function isHandling(array $record)
45  {
46  foreach ($this->handlers as $handler) {
47  if ($handler->isHandling($record)) {
48  return true;
49  }
50  }
51 
52  return false;
53  }
54 
58  public function handle(array $record)
59  {
60  if ($this->processors) {
61  foreach ($this->processors as $processor) {
62  $record = call_user_func($processor, $record);
63  }
64  }
65 
66  foreach ($this->handlers as $handler) {
67  $handler->handle($record);
68  }
69 
70  return false === $this->bubble;
71  }
72 
76  public function handleBatch(array $records)
77  {
78  if ($this->processors) {
79  $processed = array();
80  foreach ($records as $record) {
81  foreach ($this->processors as $processor) {
82  $processed[] = call_user_func($processor, $record);
83  }
84  }
85  $records = $processed;
86  }
87 
88  foreach ($this->handlers as $handler) {
89  $handler->handleBatch($records);
90  }
91  }
92 
97  {
98  foreach ($this->handlers as $handler) {
99  $handler->setFormatter($formatter);
100  }
101 
102  return $this;
103  }
104 }
Base Handler class providing the Handler structure.
__construct(array $handlers, $bubble=true)
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}
Create styles array
The data for the language used.
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.
handleBatch(array $records)
{Handles a set of records at once.The records to handle (an array of record arrays)} ...