Skip to content

Commit 5170f75

Browse files
authored
Merge branch 'main' into chore/remove-unused-lint
2 parents 8633967 + a489482 commit 5170f75

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

logconsumer_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,24 @@ func Test_StartLogProductionStillStartsWithTooHighTimeout(t *testing.T) {
503503

504504
// bufLogger is a Logging implementation that writes to a bytes.Buffer.
505505
type bufLogger struct {
506-
bytes.Buffer
506+
mtx sync.Mutex
507+
buf bytes.Buffer
507508
}
508509

509510
// Printf implements Logging.
510511
func (l *bufLogger) Printf(format string, v ...any) {
511-
fmt.Fprintf(l, format, v...)
512+
l.mtx.Lock()
513+
defer l.mtx.Unlock()
514+
515+
fmt.Fprintf(&l.buf, format, v...)
516+
}
517+
518+
// String returns the contents of the buffer as a string.
519+
func (l *bufLogger) String() string {
520+
l.mtx.Lock()
521+
defer l.mtx.Unlock()
522+
523+
return l.buf.String()
512524
}
513525

514526
func Test_MultiContainerLogConsumer_CancelledContext(t *testing.T) {

0 commit comments

Comments
 (0)