forked from rai-project/tracer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel.go
51 lines (46 loc) · 907 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package tracer
type Level int32
const (
NO_TRACE Level = iota
APPLICATION_TRACE
MODEL_TRACE
FRAMEWORK_TRACE
ML_LIBRARY_TRACE
SYSTEM_LIBRARY_TRACE
HARDWARE_TRACE
FULL_TRACE
LIBRARY_TRACE = ML_LIBRARY_TRACE
)
func LevelFromName(s string) Level {
if s == "" {
return Config.Level
}
lvl, err := LevelString(s)
if err != nil {
log.WithError(err).Errorf("invalid level spec %v", s)
return NO_TRACE
}
return lvl
}
func LevelToName(l Level) string {
switch l {
case NO_TRACE:
return "NO_TRACE"
case APPLICATION_TRACE:
return "APPLICATION_TRACE"
case MODEL_TRACE:
return "MODEL_TRACE"
case FRAMEWORK_TRACE:
return "FRAMEWORK_TRACE"
case ML_LIBRARY_TRACE:
return "ML_LIBRARY_TRACE"
case SYSTEM_LIBRARY_TRACE:
return "SYSTEM_LIBRARY_TRACE"
case HARDWARE_TRACE:
return "HARDWARE_TRACE"
case FULL_TRACE:
return "FULL_TRACE"
default:
panic("unknow trace level")
}
}