/
formatter_themes.go
99 lines (92 loc) · 3.71 KB
/
formatter_themes.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package log
import "gopkg.in/jucardi/go-terminal-colors.v1"
// LevelColorScheme represents the terminal colors associated to the level parsing for each logging level.
type LevelColorScheme map[Level][]fmtc.Color
// TerminalColorScheme defines terminal colors that are tied to a log level and a field.
type TerminalColorScheme map[string]LevelColorScheme
// TerminalTheme contains the logging theme configuration for terminal logging
type TerminalTheme struct {
Template string
Schemes TerminalColorScheme
}
var (
TerminalThemeDefault = &TerminalTheme{
Template: `{{ LoggerName . }}{{ Level . }}{{ Timestamp " HH:mm:ss " . }} {{ .Message }}`,
Schemes: TerminalColorScheme{
"loggerName": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
InfoLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
WarnLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
FatalLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
PanicLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
},
"level": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Bold, fmtc.DarkGray},
InfoLevel: []fmtc.Color{fmtc.Bold, fmtc.Cyan},
WarnLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.Bold, fmtc.Red},
FatalLevel: []fmtc.Color{fmtc.Bold, fmtc.Red},
PanicLevel: []fmtc.Color{fmtc.Bold, fmtc.Red},
},
"timestamp": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.DarkGray},
InfoLevel: []fmtc.Color{fmtc.Cyan},
WarnLevel: []fmtc.Color{fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.Red},
FatalLevel: []fmtc.Color{fmtc.Red},
PanicLevel: []fmtc.Color{fmtc.Red},
},
},
}
TerminalThemeAlternative = &TerminalTheme{
Template: `{{ LoggerName . }}{{ Scheme "level" (string " " .Level " ") . }}{{ Timestamp " HH:mm:ss " . }} {{ .Message }}`,
Schemes: TerminalColorScheme{
"loggerName": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
InfoLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
WarnLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
FatalLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
PanicLevel: []fmtc.Color{fmtc.Bold, fmtc.Yellow},
},
"level": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Bold, fmtc.DarkGray},
InfoLevel: []fmtc.Color{fmtc.Bold, fmtc.White, fmtc.BgBlue},
WarnLevel: []fmtc.Color{fmtc.Black, fmtc.BgYellow},
ErrorLevel: []fmtc.Color{fmtc.Bold, fmtc.White, fmtc.BgRed},
FatalLevel: []fmtc.Color{fmtc.Bold, fmtc.White, fmtc.BgRed},
PanicLevel: []fmtc.Color{fmtc.Bold, fmtc.White, fmtc.BgRed},
},
"timestamp": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.BgBlack, fmtc.DarkGray},
InfoLevel: []fmtc.Color{fmtc.BgBlack, fmtc.Cyan},
WarnLevel: []fmtc.Color{fmtc.BgBlack, fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.BgBlack, fmtc.Red},
FatalLevel: []fmtc.Color{fmtc.BgBlack, fmtc.Red},
PanicLevel: []fmtc.Color{fmtc.BgBlack, fmtc.Red},
},
},
}
TerminalThemeCliApp = &TerminalTheme{
Template: `{{ Timestamp " HH:mm:ss " . }} {{ Message . " " }}`,
Schemes: TerminalColorScheme{
"timestamp": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Gray},
InfoLevel: []fmtc.Color{fmtc.Cyan},
WarnLevel: []fmtc.Color{fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.Red},
FatalLevel: []fmtc.Color{fmtc.Red},
PanicLevel: []fmtc.Color{fmtc.Red},
},
"message": LevelColorScheme{
DebugLevel: []fmtc.Color{fmtc.Gray},
InfoLevel: []fmtc.Color{fmtc.White},
WarnLevel: []fmtc.Color{fmtc.Yellow},
ErrorLevel: []fmtc.Color{fmtc.LightRed},
FatalLevel: []fmtc.Color{fmtc.LightRed},
PanicLevel: []fmtc.Color{fmtc.LightRed},
},
},
}
)