forked from ryanbagwell/wordpress-sentry
/
class.wp-raven-client.php
executable file
·62 lines (45 loc) · 1.27 KB
/
class.wp-raven-client.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once( dirname(__FILE__) . '/raven/lib/Raven/Autoloader.php' );
Raven_Autoloader::register();
class WP_Raven_Client extends Raven_Client {
protected $settings;
/**
* @var array
*/
protected $errorLevelMap;
public function __construct() {
$this->errorLevelMap = array(
'E_NONE' => 0,
'E_ERROR' => 1,
'E_WARNING' => 2,
'E_PARSE' => 4,
'E_NOTICE' => 8,
'E_USER_ERROR' => 256,
'E_USER_WARNING' => 512,
'E_USER_NOTICE' => 1024,
'E_RECOVERABLE_ERROR' => 4096,
'E_ALL' => 8191);
$this->settings = get_option('sentry-settings');
if (!isset($this->settings['dsn']))
return;
if ($this->settings['dsn'] == '')
return;
parent::__construct($this->settings['dsn']);
$this->setErrorReportingLevel(
$this->settings['reporting_level']);
$this->setHandlers();
}
private function setHandlers() {
$error_handler = new Raven_ErrorHandler($this);
set_error_handler(array($error_handler, 'handleError'));
set_exception_handler(array($error_handler, 'handleException'));
}
private function setErrorReportingLevel($level = 'E_ERROR') {
try {
$this->_max_error_reporting_level = $this->errorLevelMap[$level];
} catch (Exception $e) {
$this->_max_error_reporting_level = $this->errorLevelMap[$level];
}
}
}
?>