-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_const.go
51 lines (47 loc) · 853 Bytes
/
log_const.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 hm_log
const (
DebugLevel = iota
TraceLevel
InfoLevel
WarnLevel
ErrorLevel
FatalLevel
)
const (
LogSplitTypeHour = iota
LogSplitTypeSize
)
func LogLevelString(level int) (levelStr string) {
switch level {
case DebugLevel:
levelStr = "DEBUG"
case TraceLevel:
levelStr = "TRACE"
case InfoLevel:
levelStr = "INFO"
case WarnLevel:
levelStr = "WARN"
case ErrorLevel:
levelStr = "ERROR"
case FatalLevel:
levelStr = "FATAL"
}
return
}
func GetLevel(level string) int {
switch level {
case "debug", "Debug", "DEBUG":
return DebugLevel
case "trace", "Trace", "TRACE":
return TraceLevel
case "info", "Info", "INFO":
return InfoLevel
case "warn", "Warn", "WARN":
return WarnLevel
case "error", "Error", "ERROR":
return ErrorLevel
case "fatal", "Fatal", "FATAL":
return FatalLevel
}
return DebugLevel
}