-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.go
54 lines (48 loc) · 1.28 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
package log
import (
"github.com/evilsocket/islazy/tui"
)
// Verbosity represents the verbosity level of the logger.
type Verbosity int
const (
// Debug messages.
DEBUG Verbosity = iota
// Informative messages.
INFO
// Informative messages that are important.
IMPORTANT
// Warning messages.
WARNING
// Recoverable error conditions.
ERROR
// Fatal error conditions.
FATAL
)
var (
// LevelNames is a map of the names ( {level:name} ) of each verbosity level.
LevelNames = map[Verbosity]string{
DEBUG: "DBG",
INFO: "INF",
IMPORTANT: "IMP",
WARNING: "WAR",
ERROR: "ERR",
FATAL: "!!!",
}
// LevelColors is a map of the colors ( {level:color} ) of each verbosity level.
LevelColors = map[Verbosity]string{
DEBUG: tui.DIM + tui.FOREBLACK + tui.BACKDARKGRAY,
INFO: tui.FOREWHITE + tui.BACKGREEN,
IMPORTANT: tui.FOREWHITE + tui.BACKLIGHTBLUE,
WARNING: tui.FOREWHITE + tui.BACKYELLOW,
ERROR: tui.FOREWHITE + tui.BACKRED,
FATAL: tui.FOREWHITE + tui.BACKRED + tui.BOLD,
}
)
// LevelName returns the name of a verbosity level.
func LevelName(v Verbosity) string {
return LevelNames[v]
}
// LevelColor returns the color of a verbosity level or "" if effects are disabled.
func LevelColor(v Verbosity) string {
return LevelColors[v]
}