-
Notifications
You must be signed in to change notification settings - Fork 10
/
status.go
50 lines (45 loc) · 1.33 KB
/
status.go
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
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package message
// Status values
const (
StatusEmergency = "emergency"
StatusAlert = "alert"
StatusCritical = "critical"
StatusError = "error"
StatusWarning = "warn"
StatusNotice = "notice"
StatusInfo = "info"
StatusDebug = "debug"
)
// Syslog severity levels
var (
SevEmergency = []byte("<40>")
SevAlert = []byte("<41>")
SevCritical = []byte("<42>")
SevError = []byte("<43>")
SevWarning = []byte("<44>")
SevNotice = []byte("<45>")
SevInfo = []byte("<46>")
SevDebug = []byte("<47>")
)
// statusSeverityMapping represents the 1:1 mapping between statuses and severities.
var statusSeverityMapping = map[string][]byte{
StatusEmergency: SevEmergency,
StatusAlert: SevAlert,
StatusCritical: SevCritical,
StatusError: SevError,
StatusWarning: SevWarning,
StatusNotice: SevNotice,
StatusInfo: SevInfo,
StatusDebug: SevDebug,
}
// StatusToSeverity transforms a severity into a status.
func StatusToSeverity(status string) []byte {
if sev, exists := statusSeverityMapping[status]; exists {
return sev
}
return SevInfo
}