Skip to content

Commit

Permalink
fix(logging): Clean up extra empty spaces when redirectLogger is used
Browse files Browse the repository at this point in the history
  • Loading branch information
zmyzheng committed Dec 3, 2024
1 parent 2636612 commit 083fd11
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions logger/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ func (l *redirectLogger) Print(level telegraf.LogLevel, ts time.Time, prefix str
for k, v := range attr {
parts = append(parts, fmt.Sprintf("%s=%v", k, v))
}
attrMsg = " (" + strings.Join(parts, ",") + ")"
attrMsg = "(" + strings.Join(parts, ",") + ")"
}

msg := append([]interface{}{ts.In(time.UTC).Format(time.RFC3339), " ", level.Indicator(), " ", prefix + attrMsg}, args...)
msg := []interface{}{ts.In(time.UTC).Format(time.RFC3339), level.Indicator(), prefix + attrMsg}
if prefix+attrMsg != "" {
msg = append(msg, prefix+attrMsg)
}
msg = append(msg, args)

fmt.Fprintln(l.writer, msg...)
}

Expand Down

0 comments on commit 083fd11

Please sign in to comment.