-
Notifications
You must be signed in to change notification settings - Fork 10
/
RollbarLogRoute.php
37 lines (31 loc) · 981 Bytes
/
RollbarLogRoute.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Rollbar\Rollbar;
use Rollbar\LevelFactory;
class RollbarLogRoute extends CLogRoute
{
public $rollbarComponentName = 'rollbar';
private $levelFactory = null;
public function init()
{
if (Yii::app()->getComponent($this->rollbarComponentName) === null) {
throw new CException('Rollbar component is not loaded.');
}
$this->levelFactory = new LevelFactory();
}
protected function processLogs($logs)
{
foreach ($logs as $log) {
// Exclude records by the exceptions handler. RollbarErrorHandler takes care of them.
if (strncmp($log[2], 'exception', 9) !== 0) {
Rollbar::log($this->levelFactory->fromName($this->correspondingLevel($log[1])), $log[0]);
}
}
}
private function correspondingLevel($level)
{
if ($level == 'trace' || $level == 'profile') {
return 'debug';
}
return $level;
}
}