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
12namespace Monolog\Handler;
13
14use RollbarNotifier;
15use Exception;
17
24{
31
37 public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
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}
Base Handler class providing the Handler structure.
Sends errors to Rollbar.
close()
{Closes the handler.This will be called automatically when the object is destroyed}
write(array $record)
{Writes the record down to the log of the implementing handler.void}
__construct(RollbarNotifier $rollbarNotifier, $level=Logger::ERROR, $bubble=true)
Monolog log channel.
Definition: Logger.php:28
const ERROR
Runtime errors.
Definition: Logger.php:57