forked from charmbracelet/log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styles.go
100 lines (84 loc) · 2.27 KB
/
styles.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
100
package log
import "github.com/charmbracelet/lipgloss"
var (
// TimestampStyle is the style for timestamps.
TimestampStyle = lipgloss.NewStyle()
// CallerStyle is the style for caller.
CallerStyle = lipgloss.NewStyle().Faint(true)
// PrefixStyle is the style for prefix.
PrefixStyle = lipgloss.NewStyle().Bold(true).Faint(true)
// MessageStyle is the style for messages.
MessageStyle = lipgloss.NewStyle()
// KeyStyle is the style for keys.
KeyStyle = lipgloss.NewStyle().Faint(true)
// ValueStyle is the style for values.
ValueStyle = lipgloss.NewStyle()
// SeparatorStyle is the style for separators.
SeparatorStyle = lipgloss.NewStyle().Faint(true)
// DebugLevel is the style for debug level.
DebugLevelStyle = lipgloss.NewStyle().
SetString("DEBUG").
Bold(true).
MaxWidth(4).
Foreground(lipgloss.AdaptiveColor{
Light: "63",
Dark: "63",
})
// InfoLevel is the style for info level.
InfoLevelStyle = lipgloss.NewStyle().
SetString("INFO").
Bold(true).
MaxWidth(4).
Foreground(lipgloss.AdaptiveColor{
Light: "39",
Dark: "86",
})
// WarnLevel is the style for warn level.
WarnLevelStyle = lipgloss.NewStyle().
SetString("WARN").
Bold(true).
MaxWidth(4).
Foreground(lipgloss.AdaptiveColor{
Light: "208",
Dark: "192",
})
// ErrorLevel is the style for error level.
ErrorLevelStyle = lipgloss.NewStyle().
SetString("ERROR").
Bold(true).
MaxWidth(4).
Foreground(lipgloss.AdaptiveColor{
Light: "203",
Dark: "204",
})
// FatalLevel is the style for error level.
FatalLevelStyle = lipgloss.NewStyle().
SetString("FATAL").
Bold(true).
MaxWidth(4).
Foreground(lipgloss.AdaptiveColor{
Light: "133",
Dark: "134",
})
// KeyStyles overrides styles for specific keys.
KeyStyles = map[string]lipgloss.Style{}
// ValueStyles overrides value styles for specific keys.
ValueStyles = map[string]lipgloss.Style{}
)
// levelStyle is a helper function to get the style for a level.
func levelStyle(level Level) lipgloss.Style {
switch level {
case DebugLevel:
return DebugLevelStyle
case InfoLevel:
return InfoLevelStyle
case WarnLevel:
return WarnLevelStyle
case ErrorLevel:
return ErrorLevelStyle
case FatalLevel:
return FatalLevelStyle
default:
return lipgloss.NewStyle()
}
}