From 272329d86a2d0dab0752de0e92f33ccd432e0ecf Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 31 Oct 2023 17:19:33 +0100 Subject: [PATCH] action: add `:` separator between ts and msg logs Signed-off-by: Hidde Beydals --- internal/action/log.go | 4 ++-- internal/action/log_test.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/action/log.go b/internal/action/log.go index 4a7fcd6..5caad3b 100644 --- a/internal/action/log.go +++ b/internal/action/log.go @@ -62,9 +62,9 @@ func (l *logLine) String() string { return "" } - msg := fmt.Sprintf("%s %s", l.ts.Format(time.RFC3339Nano), l.msg) + msg := fmt.Sprintf("%s: %s", l.ts.Format(time.RFC3339Nano), l.msg) if c := l.count; c > 0 { - msg += fmt.Sprintf("\n%s %s", l.lastTS.Format(time.RFC3339Nano), l.msg) + msg += fmt.Sprintf("\n%s: %s", l.lastTS.Format(time.RFC3339Nano), l.msg) } if c := l.count - 1; c > 0 { var dup = "line" diff --git a/internal/action/log_test.go b/internal/action/log_test.go index 5e01f18..16aab7d 100644 --- a/internal/action/log_test.go +++ b/internal/action/log_test.go @@ -34,7 +34,7 @@ func TestLogBuffer_Log(t *testing.T) { wantCount int want string }{ - {name: "log", size: 2, fill: []string{"a", "b", "c"}, wantCount: 3, want: fmt.Sprintf("%[1]s b\n%[1]s c", stubNowTS().Format(time.RFC3339Nano))}, + {name: "log", size: 2, fill: []string{"a", "b", "c"}, wantCount: 3, want: fmt.Sprintf("%[1]s: b\n%[1]s: c", stubNowTS().Format(time.RFC3339Nano))}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -115,11 +115,11 @@ func TestLogBuffer_String(t *testing.T) { want string }{ {name: "empty buffer", fill: []string{}, want: ""}, - {name: "filled buffer", size: 2, fill: []string{"a", "b", "c"}, want: fmt.Sprintf("%[1]s b\n%[1]s c", stubNowTS().Format(time.RFC3339Nano))}, - {name: "duplicate buffer items", fill: []string{"b", "b"}, want: fmt.Sprintf("%[1]s b\n%[1]s b", stubNowTS().Format(time.RFC3339Nano))}, - {name: "duplicate buffer items", fill: []string{"b", "b", "b"}, want: fmt.Sprintf("%[1]s b\n%[1]s b (1 duplicate line omitted)", stubNowTS().Format(time.RFC3339Nano))}, - {name: "duplicate buffer items", fill: []string{"b", "b", "b", "b"}, want: fmt.Sprintf("%[1]s b\n%[1]s b (2 duplicate lines omitted)", stubNowTS().Format(time.RFC3339Nano))}, - {name: "duplicate buffer items", fill: []string{"a", "b", "b", "b", "c", "c"}, want: fmt.Sprintf("%[1]s a\n%[1]s b\n%[1]s b (1 duplicate line omitted)\n%[1]s c\n%[1]s c", stubNowTS().Format(time.RFC3339Nano))}, + {name: "filled buffer", size: 2, fill: []string{"a", "b", "c"}, want: fmt.Sprintf("%[1]s: b\n%[1]s: c", stubNowTS().Format(time.RFC3339Nano))}, + {name: "duplicate buffer items", fill: []string{"b", "b"}, want: fmt.Sprintf("%[1]s: b\n%[1]s: b", stubNowTS().Format(time.RFC3339Nano))}, + {name: "duplicate buffer items", fill: []string{"b", "b", "b"}, want: fmt.Sprintf("%[1]s: b\n%[1]s: b (1 duplicate line omitted)", stubNowTS().Format(time.RFC3339Nano))}, + {name: "duplicate buffer items", fill: []string{"b", "b", "b", "b"}, want: fmt.Sprintf("%[1]s: b\n%[1]s: b (2 duplicate lines omitted)", stubNowTS().Format(time.RFC3339Nano))}, + {name: "duplicate buffer items", fill: []string{"a", "b", "b", "b", "c", "c"}, want: fmt.Sprintf("%[1]s: a\n%[1]s: b\n%[1]s: b (1 duplicate line omitted)\n%[1]s: c\n%[1]s: c", stubNowTS().Format(time.RFC3339Nano))}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {