ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
27{
34
40 private $hasRecords = false;
41
47 public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
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}
An exception for terminatinating execution or to throw for unit testing.
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