From 7d172c9899aacf0eff65febd560a92c53c632664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sedl=C3=A1=C4=8Dek?= Date: Mon, 19 Aug 2024 09:50:58 +0200 Subject: [PATCH] removed equal signs from groups --- devslog.go | 3 +-- devslog_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/devslog.go b/devslog.go index e1185dd..5df2b96 100644 --- a/devslog.go +++ b/devslog.go @@ -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)...) } diff --git a/devslog_test.go b/devslog_test.go index 1aa87fe..a5a2695 100644 --- a/devslog_test.go +++ b/devslog_test.go @@ -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) @@ -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) @@ -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) @@ -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)