ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RollbarHandler.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 
14 use RollbarNotifier;
15 use Exception;
16 use Monolog\Logger;
17 
27 {
33  protected $rollbarNotifier;
34 
40  private $hasRecords = false;
41 
48  {
49  $this->rollbarNotifier = $rollbarNotifier;
50 
51  parent::__construct($level, $bubble);
52  }
53 
57  protected function write(array $record)
58  {
59  if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
60  $context = $record['context'];
61  $exception = $context['exception'];
62  unset($context['exception']);
63 
64  $payload = array();
65  if (isset($context['payload'])) {
66  $payload = $context['payload'];
67  unset($context['payload']);
68  }
69 
70  $this->rollbarNotifier->report_exception($exception, $context, $payload);
71  } else {
72  $extraData = array(
73  'level' => $record['level'],
74  'channel' => $record['channel'],
75  'datetime' => $record['datetime']->format('U'),
76  );
77 
78  $context = $record['context'];
79  $payload = array();
80  if (isset($context['payload'])) {
81  $payload = $context['payload'];
82  unset($context['payload']);
83  }
84 
85  $this->rollbarNotifier->report_message(
86  $record['message'],
87  $record['level_name'],
88  array_merge($record['context'], $record['extra'], $extraData),
89  $payload
90  );
91  }
92 
93  $this->hasRecords = true;
94  }
95 
99  public function close()
100  {
101  if ($this->hasRecords) {
102  $this->rollbarNotifier->flush();
103  $this->hasRecords = false;
104  }
105  }
106 }
const ERROR
Runtime errors.
Definition: Logger.php:57
Base Handler class providing the Handler structure.
__construct(RollbarNotifier $rollbarNotifier, $level=Logger::ERROR, $bubble=true)
Create styles array
The data for the language used.
Sends errors to Rollbar.
Write to Excel2007 format