-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathErrbitCakePHP.php
More file actions
73 lines (64 loc) · 2.5 KB
/
ErrbitCakePHP.php
File metadata and controls
73 lines (64 loc) · 2.5 KB
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
63
64
65
66
67
68
69
70
71
72
73
<?php
App::uses('Errbit', 'Lib/vo-errbit-cake/errbit/lib');
class ErrbitCakePHP extends ErrorHandler{
public static $settings;
private $errbit;
function __construct(){
$this->errbit = Errbit::instance();
$this->errbit->configure(array(
'api_key' => self::$settings['api_key'],
'host' => self::$settings['host'],
'port' => self::$settings['port'],
'secure' => false,
'project_root' => '/',
'environment_name' => self::$settings['environment_name'],
'params_filters' => array('/password/', '/card_number/'),
'backtrace_filters' => array('#/some/long/path#' => '')
));
}
public static function handleError($code, $description, $file = null, $line = null, $context = null) {
$errbitCake = new ErrbitCakePHP();
$errbitCake->onError($code, $description, $file, $line);
return parent::handleError($code, $description, $file, $line, $context);
}
public static function handleException(Exception $exception) {
$errbitCake = new ErrbitCakePHP();
$errbitCake->onException($exception);
return parent::handleException($exception);
}
public function onError($code, $message, $file, $line) {
$sendNotify = true;
switch ($code) {
case E_USER_NOTICE:
case E_NOTICE:
if( !self::$settings['showNotice'] ){
$sendNotify = false;
break;
}
$exception = new Errbit_Errors_Notice($message, $file, $line, debug_backtrace());
break;
case E_WARNING:
case E_USER_WARNING:
if( !self::$settings['showWarnigns'] ){
$sendNotify = false;
break;
}
$exception = new Errbit_Errors_Warning($message, $file, $line, debug_backtrace());
break;
case E_ERROR:
case E_USER_ERROR:
default:
if( !self::$settings['showErrors'] ){
$sendNotify = false;
break;
}
$exception = new Errbit_Errors_Error($message, $file, $line, debug_backtrace());
}
if( $sendNotify ){
$this->errbit->notify($exception);
}
}
public function onException($exception) {
$this->errbit->notify($exception);
}
}