-
Notifications
You must be signed in to change notification settings - Fork 66
/
styles.go
82 lines (69 loc) · 2.09 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
package log
import (
"strings"
"github.com/charmbracelet/lipgloss"
)
// Styles defines the styles for the text logger.
type Styles struct {
// Timestamp is the style for timestamps.
Timestamp lipgloss.Style
// Caller is the style for source caller.
Caller lipgloss.Style
// Prefix is the style for prefix.
Prefix lipgloss.Style
// Message is the style for messages.
Message lipgloss.Style
// Key is the style for keys.
Key lipgloss.Style
// Value is the style for values.
Value lipgloss.Style
// Separator is the style for separators.
Separator lipgloss.Style
// Levels are the styles for each level.
Levels map[Level]lipgloss.Style
// Keys overrides styles for specific keys.
Keys map[string]lipgloss.Style
// Values overrides value styles for specific keys.
Values map[string]lipgloss.Style
}
// DefaultStyles returns the default styles.
func DefaultStyles() *Styles {
return &Styles{
Timestamp: lipgloss.NewStyle(),
Caller: lipgloss.NewStyle().Faint(true),
Prefix: lipgloss.NewStyle().Bold(true).Faint(true),
Message: lipgloss.NewStyle(),
Key: lipgloss.NewStyle().Faint(true),
Value: lipgloss.NewStyle(),
Separator: lipgloss.NewStyle().Faint(true),
Levels: map[Level]lipgloss.Style{
DebugLevel: lipgloss.NewStyle().
SetString(strings.ToUpper(DebugLevel.String())).
Bold(true).
MaxWidth(4).
Foreground(lipgloss.Color("63")),
InfoLevel: lipgloss.NewStyle().
SetString(strings.ToUpper(InfoLevel.String())).
Bold(true).
MaxWidth(4).
Foreground(lipgloss.Color("86")),
WarnLevel: lipgloss.NewStyle().
SetString(strings.ToUpper(WarnLevel.String())).
Bold(true).
MaxWidth(4).
Foreground(lipgloss.Color("192")),
ErrorLevel: lipgloss.NewStyle().
SetString(strings.ToUpper(ErrorLevel.String())).
Bold(true).
MaxWidth(4).
Foreground(lipgloss.Color("204")),
FatalLevel: lipgloss.NewStyle().
SetString(strings.ToUpper(FatalLevel.String())).
Bold(true).
MaxWidth(4).
Foreground(lipgloss.Color("134")),
},
Keys: map[string]lipgloss.Style{},
Values: map[string]lipgloss.Style{},
}
}