From 83843a532df6ca781a3490e6c90721d1a3d9eeb6 Mon Sep 17 00:00:00 2001 From: vicluq Date: Wed, 6 Nov 2024 19:19:54 -0300 Subject: [PATCH] fixed panic when keyvals len equals 1 --- pkg/kgo/logger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/kgo/logger.go b/pkg/kgo/logger.go index bfc5dc0d..a98c595a 100644 --- a/pkg/kgo/logger.go +++ b/pkg/kgo/logger.go @@ -89,7 +89,9 @@ func (b *basicLogger) Log(level LogLevel, msg string, keyvals ...any) { if len(keyvals) > 0 { buf.WriteString("; ") format := strings.Repeat("%v: %v, ", len(keyvals)/2) - format = format[:len(format)-2] // trim trailing comma and space + if len(format) > 1 { + format = format[:len(format)-2] // trim trailing comma and space + } fmt.Fprintf(buf, format, keyvals...) }