-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel.go
More file actions
54 lines (41 loc) · 1.28 KB
/
level.go
File metadata and controls
54 lines (41 loc) · 1.28 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
package logger
import "go.uber.org/zap/zapcore"
// Level is the logging priority. Higher levels are more important.
type Level uint8
func (l Level) toZapCoreLevel() zapcore.Level {
if l.isValid() {
return levelMap[l]
}
return levelMap[InfoLevel]
}
func (l Level) isValid() bool {
return l <= FatalLevel
}
const (
// DebugLevel are typically used on development environemt or for debug purpose.
// Is more voluminous and are usually disabled in production.
DebugLevel Level = iota
// InfoLevel is the default logging priority.
InfoLevel
// WarnLevel logs are more important than Info, but not critical
WarnLevel
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-level logs.
ErrorLevel
// DPanicLevel logs are particularly important errors. In development the
// logger panics after writing the message.
DPanicLevel
// PanicLevel logs a message, then panics.
PanicLevel
// FatalLevel logs a message, then calls os.Exit(1).
FatalLevel
)
var levelMap = map[Level]zapcore.Level{
DebugLevel: zapcore.DebugLevel,
InfoLevel: zapcore.InfoLevel,
WarnLevel: zapcore.WarnLevel,
ErrorLevel: zapcore.ErrorLevel,
DPanicLevel: zapcore.DPanicLevel,
PanicLevel: zapcore.PanicLevel,
FatalLevel: zapcore.FatalLevel,
}