1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VojtaSvoboda\ErrorLogger\Models; |
4
|
|
|
|
5
|
|
|
use October\Rain\Database\Model; |
6
|
|
|
use October\Rain\Database\Traits\Validation as ValidationTrait; |
7
|
|
|
|
8
|
|
|
class Settings extends Model |
9
|
|
|
{ |
10
|
|
|
use ValidationTrait; |
11
|
|
|
|
12
|
|
|
public $implement = ['System.Behaviors.SettingsModel']; |
13
|
|
|
|
14
|
|
|
// A unique code |
15
|
|
|
public $settingsCode = 'vojtasvoboda_errorlogger_settings'; |
16
|
|
|
|
17
|
|
|
// Reference to field configuration |
18
|
|
|
public $settingsFields = 'fields.yaml'; |
19
|
|
|
|
20
|
|
|
public $rules = [ |
21
|
|
|
'nativemailer_email' => 'required_if:nativemailer_enabled,1', |
22
|
|
|
'slack_token' => 'required_if:slack_enabled,1', |
23
|
|
|
'slack_channel' => 'required_if:slack_enabled,1', |
24
|
|
|
'slack_username' => 'required_if:slack_enabled,1', |
25
|
|
|
'syslog_ident' => 'required_if:syslog_enabled,1', |
26
|
|
|
'syslog_facility' => 'required_if:syslog_enabled,1', |
27
|
|
|
'newrelic_appname' => 'required_if:newrelic_enabled,1', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
public $attributeNames = [ |
31
|
|
|
'nativemailer_email' => 'Developer email', |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
public static function getNativemailerLevelOptions() |
35
|
|
|
{ |
36
|
|
|
return self::getErrorLevelOptions(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static function getSlackLevelOptions() |
40
|
|
|
{ |
41
|
|
|
return self::getErrorLevelOptions(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function getSyslogLevelOptions() |
45
|
|
|
{ |
46
|
|
|
return self::getErrorLevelOptions(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public static function getNewrelicLevelOptions() |
50
|
|
|
{ |
51
|
|
|
return self::getErrorLevelOptions(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public static function getErrorLevelOptions() |
55
|
|
|
{ |
56
|
|
|
return [ |
57
|
|
|
100 => 'Debug - Level 100 - Detailed debug information', |
58
|
|
|
200 => 'Info - Level 200 - Interesting events e.g. user logs in, SQL logs', |
59
|
|
|
250 => 'Notice - Level 250 - Uncommon events', |
60
|
|
|
300 => 'Warning - Level 300 - Exceptional occurrences that are not errors', |
61
|
|
|
400 => 'Error - Level 400 - Runtime errors', |
62
|
|
|
500 => 'Critical - Level 500 - Critical conditions', |
63
|
|
|
550 => 'Alert - Level 550 - Action must be taken immediately', |
64
|
|
|
600 => 'Emergency - Level 600 - Urgent alert' |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|