Skip to content

Commit

Permalink
log/stdlog: skip empty labels
Browse files Browse the repository at this point in the history
Without this patch we can emit empty labels like "[]".
  • Loading branch information
mmatczuk committed Dec 12, 2023
1 parent 14b3829 commit 8740108
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions log/stdlog/stdlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func logLinePrefix(labels []string, name, level string) string {
all := append(labels[0:len(labels):len(labels)], name, level) //nolint:gocritic // all is good we always create new slice
var sb strings.Builder
for _, l := range all {
if l == "" {
continue
}
sb.WriteString("[")
sb.WriteString(l)
sb.WriteString("] ")
Expand Down

0 comments on commit 8740108

Please sign in to comment.