-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.go
71 lines (67 loc) · 1.16 KB
/
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
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
package blackbox
const (
// Trace log level
Trace Level = iota
// Debug log level
Debug
// Verbose log level
Verbose
// Info log level
Info
// Warn log level
Warn
// Error log level
Error
// Fatal log level
Fatal
// Panic log level
Panic
)
// Level indicates the logging level to be used when logging messages.
type Level int
// LevelFromString returns a log level matching the given string
func LevelFromString(levelStr string) Level {
var level Level
switch levelStr {
case "trace":
level = Trace
case "debug":
level = Debug
case "verbose":
level = Verbose
case "info":
level = Info
case "warn":
level = Warn
case "error":
level = Error
case "fatal":
level = Fatal
case "panic":
level = Panic
}
return level
}
// String returns the string representation of each Level constant
func (l Level) String() string {
var levelStr string
switch l {
case Trace:
levelStr = "trace"
case Debug:
levelStr = "debug"
case Verbose:
levelStr = "verbose"
case Info:
levelStr = "info"
case Warn:
levelStr = "warn"
case Error:
levelStr = "error"
case Fatal:
levelStr = "fatal"
case Panic:
levelStr = "panic"
}
return levelStr
}