-
Notifications
You must be signed in to change notification settings - Fork 2
/
levels.go
48 lines (43 loc) · 801 Bytes
/
levels.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
package logo
// Level is a log level
type Level int
// Available log levels
const (
DEBUG Level = iota
INFO
WARN
ERROR
FATAL
)
// Options to store the key, level and color code of a log
type levelOptions struct {
Key string
Level Level
Color int
}
// Log options for all levels
var (
optDebug = &levelOptions{"DEBU", DEBUG, 34}
optInfo = &levelOptions{"INFO", INFO, 32}
optWarn = &levelOptions{"WARN", WARN, 33}
optError = &levelOptions{"ERRO", ERROR, 31}
optFatal = &levelOptions{"CRIT", FATAL, 31}
)
// Itol converts an integer to a logo.Level
// TODO is it possible to cast somehow?
func Itol(level int) Level {
switch level {
case 0:
return DEBUG
case 1:
return INFO
case 2:
return WARN
case 3:
return ERROR
case 4:
return FATAL
default:
return DEBUG
}
}