-
Notifications
You must be signed in to change notification settings - Fork 1
/
level.go
52 lines (45 loc) · 851 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
52
// Copyright 2018 The OpenPitrix Authors. All rights reserved.
// Use of this source code is governed by a Apache license
// that can be found in the LICENSE file.
package logger
import (
"strings"
)
type Level uint32
const (
CriticalLevel Level = iota
ErrorLevel
WarnLevel
InfoLevel
DebugLevel
)
func (level Level) String() string {
switch level {
case DebugLevel:
return "DEBUG"
case InfoLevel:
return "INFO"
case WarnLevel:
return "WARNING"
case ErrorLevel:
return "ERROR"
case CriticalLevel:
return "CRITICAL"
}
return "UNKNOWN"
}
func StringToLevel(level string) Level {
switch strings.ToUpper(level) {
case "CRITICAL":
return CriticalLevel
case "ERROR":
return ErrorLevel
case "WARN", "WARNING":
return WarnLevel
case "DEBUG":
return DebugLevel
case "INFO":
return InfoLevel
}
return InfoLevel
}