Skip to content

Commit

Permalink
removed equal signs from groups
Browse files Browse the repository at this point in the history
  • Loading branch information
david-littlefarmer committed Aug 19, 2024
1 parent d10c886 commit 7d172c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions devslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ func (h *developHandler) colorize(b []byte, as attributes, l int, g []string) []
ga = a.Value.Group()
g = append(g, a.Key)

v = cs([]byte("============"), fgGreen)
v = append(v, '\n')
v = []byte("\n")
v = append(v, h.colorize(nil, ga, l+1, g)...)
}

Expand Down
10 changes: 6 additions & 4 deletions devslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func test_WithGroups(t *testing.T) {
slog.Any("a", "1"),
)

expected := fmt.Sprint("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mMy INFO message\x1b[0m\n\x1b[32mG\x1b[0m \x1b[35mtest_group\x1b[0m: \x1b[32m============\x1b[0m\n \x1b[35ma\x1b[0m: 1\n\n")
expected := "\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mMy INFO message\x1b[0m\n\x1b[32mG\x1b[0m \x1b[35mtest_group\x1b[0m: \n \x1b[35ma\x1b[0m: 1\n\n"

if !bytes.Equal(w.WrittenData, []byte(expected)) {
t.Errorf("\nExpected:\n%s\nGot:\n%s\nExpected:\n%[1]q\nGot:\n%[2]q", expected, w.WrittenData)
Expand Down Expand Up @@ -749,7 +749,7 @@ func test_Group(t *testing.T, o *Options) {
),
)

expected := []byte("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mmsg\x1b[0m\n \x1b[35m1\x1b[0m: a\n\x1b[32mG\x1b[0m \x1b[35mg\x1b[0m: \x1b[32m============\x1b[0m\n \x1b[35m2\x1b[0m: b\n\n")
expected := []byte("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mmsg\x1b[0m\n \x1b[35m1\x1b[0m: a\n\x1b[32mG\x1b[0m \x1b[35mg\x1b[0m: \n \x1b[35m2\x1b[0m: b\n\n")

if !bytes.Equal(w.WrittenData, expected) {
t.Errorf("\nExpected:\n%s\nGot:\n%s\nExpected:\n%[1]q\nGot:\n%[2]q", expected, w.WrittenData)
Expand Down Expand Up @@ -779,7 +779,7 @@ func test_LogValuer(t *testing.T, o *Options) {
slog.Any("item1", item1),
)

expected := []byte("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mtest_log_valuer\x1b[0m\n\x1b[32mG\x1b[0m \x1b[35mitem1\x1b[0m: \x1b[32m============\x1b[0m\n \x1b[33m#\x1b[0m \x1b[35mA\x1b[0m: \x1b[33m5\x1b[0m\n \x1b[35mB\x1b[0m: test\n\n")
expected := []byte("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mtest_log_valuer\x1b[0m\n\x1b[32mG\x1b[0m \x1b[35mitem1\x1b[0m: \n \x1b[33m#\x1b[0m \x1b[35mA\x1b[0m: \x1b[33m5\x1b[0m\n \x1b[35mB\x1b[0m: test\n\n")

if !bytes.Equal(w.WrittenData, expected) {
t.Errorf("\nExpected:\n%s\nGot:\n%s\nExpected:\n%[1]q\nGot:\n%[2]q", expected, w.WrittenData)
Expand Down Expand Up @@ -855,7 +855,9 @@ func test_StringerInner(t *testing.T, o *Options) {
slog.Any("item1", item1),
)

expected := []byte("\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mtest_stringer_inner\x1b[0m\n\x1b[33mS\x1b[0m \x1b[35mitem1\x1b[0m: \x1b[33md\x1b[0m\x1b[33me\x1b[0m\x1b[33mv\x1b[0m\x1b[33ms\x1b[0m\x1b[33ml\x1b[0m\x1b[33mo\x1b[0m\x1b[33mg\x1b[0m\x1b[33m.\x1b[0m\x1b[33ml\x1b[0m\x1b[33mo\x1b[0m\x1b[33mg\x1b[0m\x1b[33mS\x1b[0m\x1b[33mt\x1b[0m\x1b[33mr\x1b[0m\x1b[33mi\x1b[0m\x1b[33mn\x1b[0m\x1b[33mg\x1b[0m\x1b[33me\x1b[0m\x1b[33mr\x1b[0m\x1b[33mE\x1b[0m\x1b[33mx\x1b[0m\x1b[33ma\x1b[0m\x1b[33mm\x1b[0m\x1b[33mp\x1b[0m\x1b[33ml\x1b[0m\x1b[33me\x1b[0m\x1b[33m2\x1b[0m\n \x1b[32mInner\x1b[0m: A: test\n \x1b[32mOther\x1b[0m: \x1b[33m42\x1b[0m\n\n")
expected := []byte(
"\x1b[2m\x1b[37m[]\x1b[0m \x1b[42m\x1b[30m INFO \x1b[0m \x1b[32mtest_stringer_inner\x1b[0m\n\x1b[33mS\x1b[0m \x1b[35mitem1\x1b[0m: \x1b[33md\x1b[0m\x1b[33me\x1b[0m\x1b[33mv\x1b[0m\x1b[33ms\x1b[0m\x1b[33ml\x1b[0m\x1b[33mo\x1b[0m\x1b[33mg\x1b[0m\x1b[33m.\x1b[0m\x1b[33ml\x1b[0m\x1b[33mo\x1b[0m\x1b[33mg\x1b[0m\x1b[33mS\x1b[0m\x1b[33mt\x1b[0m\x1b[33mr\x1b[0m\x1b[33mi\x1b[0m\x1b[33mn\x1b[0m\x1b[33mg\x1b[0m\x1b[33me\x1b[0m\x1b[33mr\x1b[0m\x1b[33mE\x1b[0m\x1b[33mx\x1b[0m\x1b[33ma\x1b[0m\x1b[33mm\x1b[0m\x1b[33mp\x1b[0m\x1b[33ml\x1b[0m\x1b[33me\x1b[0m\x1b[33m2\x1b[0m\n \x1b[32mInner\x1b[0m: A: test\n \x1b[32mOther\x1b[0m: \x1b[33m42\x1b[0m\n\n",
)

if !bytes.Equal(w.WrittenData, expected) {
t.Errorf("\nExpected:\n%s\nGot:\n%s\nExpected:\n%[1]q\nGot:\n%[2]q", expected, w.WrittenData)
Expand Down

0 comments on commit 7d172c9

Please sign in to comment.