Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func TestThemes(t *testing.T) {
for _, theme := range []Theme{
NewDefaultTheme(),
NewBrightTheme(),
NewDimTheme(),
} {
t.Run(theme.Name(), func(t *testing.T) {
level := slog.LevelInfo
Expand All @@ -292,6 +293,7 @@ func TestThemes(t *testing.T) {
timeFormat := time.Kitchen
index := -1
toIndex := -1
var lastField []byte
h := NewHandler(&buf, &HandlerOptions{
AddSource: true,
TimeFormat: timeFormat,
Expand All @@ -309,6 +311,7 @@ func TestThemes(t *testing.T) {
bufBytes = bufBytes[toIndex:]
index = bytes.IndexByte(bufBytes, '\x1b')
AssertNotEqual(t, -1, index)
lastField = bufBytes[:index]
toIndex = index + len(ResetMod)
AssertEqual(t, ResetMod, ANSIMod(bufBytes[index:toIndex]))
bufBytes = bufBytes[toIndex:]
Expand Down Expand Up @@ -352,9 +355,16 @@ func TestThemes(t *testing.T) {
checkANSIMod(t, "AttrKey", theme.AttrKey())
}

// AttrValue
if theme.AttrValue() != "" {
checkANSIMod(t, "AttrValue", theme.AttrValue())
if string(lastField) == "error=" {
// AttrValueError
if theme.AttrValueError() != "" {
checkANSIMod(t, "AttrValueError", theme.AttrValueError())
}
} else {
// AttrValue
if theme.AttrValue() != "" {
checkANSIMod(t, "AttrValue", theme.AttrValue())
}
}
}
})
Expand Down
17 changes: 17 additions & 0 deletions theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,20 @@ func NewBrightTheme() Theme {
levelDebug: ToANSICode(),
}
}

func NewDimTheme() Theme {
return ThemeDef{
name: "Dim",
timestamp: ToANSICode(BrightBlack),
source: ToANSICode(Bold, BrightBlack),
message: ToANSICode(Bold),
messageDebug: ToANSICode(),
attrKey: ToANSICode(Blue),
attrValue: ToANSICode(Gray),
attrValueError: ToANSICode(Bold, Red),
levelError: ToANSICode(Red),
levelWarn: ToANSICode(Yellow),
levelInfo: ToANSICode(Green),
levelDebug: ToANSICode(),
}
}