-
Notifications
You must be signed in to change notification settings - Fork 1
/
level.go
37 lines (33 loc) · 935 Bytes
/
level.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
package wzap
import (
"strings"
)
// A Level is a logging priority. Higher levels are more important.
const (
// DebugLevel logs are typically voluminous, and are usually disabled in
// production.
DebugLevel = 1 << iota
// InfoLevel is the default logging priority.
InfoLevel
// WarnLevel logs are more important than Info, but don't need individual
// human review.
WarnLevel
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-Level logs.
ErrorLevel
// PanicLevel logs a message, then panics.
PanicLevel
// FatalLevel logs a message, then calls os.Exit(1).
FatalLevel
)
func parseLevel(desc string, delim string) (level int) {
lvs := strings.Split(strings.TrimSpace(desc), delim)
if len(lvs) == 0 {
level |= InfoLevel | WarnLevel | ErrorLevel | PanicLevel | FatalLevel
} else {
for _, lv := range lvs {
level |= levelMap(lv)
}
}
return
}