ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
24 {
30  protected $rollbarNotifier;
31 
38  {
39  $this->rollbarNotifier = $rollbarNotifier;
40 
41  parent::__construct($level, $bubble);
42  }
43 
47  protected function write(array $record)
48  {
49  if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
50  $this->rollbarNotifier->report_exception($record['context']['exception']);
51  } else {
52  $extraData = array(
53  'level' => $record['level'],
54  'channel' => $record['channel'],
55  'datetime' => $record['datetime']->format('U'),
56  );
57 
58  $this->rollbarNotifier->report_message(
59  $record['message'],
60  $record['level_name'],
61  array_merge($record['context'], $record['extra'], $extraData)
62  );
63  }
64  }
65 
69  public function close()
70  {
71  $this->rollbarNotifier->flush();
72  }
73 }
const ERROR
Runtime errors.
Definition: Logger.php:57
Base Handler class providing the Handler structure.
__construct(RollbarNotifier $rollbarNotifier, $level=Logger::ERROR, $bubble=true)
Sends errors to Rollbar.