-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(logging): Clean up extra empty spaces when redirectLogger is used #16255
Conversation
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zmyzheng thanks for your contribution! I do have two small questions in the code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution and your thorough explanation!
Summary
This PR removes the extra spaces in logging when redirectLogger is used.
prefix
andattrMsg
Example log contents:

The fix includes 3 aspects:
" "
amongts.In(time.UTC).Format(time.RFC3339)
,level.Indicator()
andprefix + attrMsg
will cause extra spaces to be generated (3 spaces rather than 1 space). This PR removes the" "
among them.prefix
is not empty, a space is added behind]
:At the same time, another space is added in front of

(
:Because of this, 2 spaces are added between

prefix
andattrMsg
:This PR removes one space between them.
prefix
andattrMsg
are empty, addingprefix + attrMsg
into msg will cause the empty string ofprefix + attrMsg
being wrapped by 2 extra empty spaces:This PR updates the logic to only add
prefix + attrMsg
into msg if it is not emptyNote: the above issues only appears whenredirectLogger is used.
Checklist
Related issues
resolves #16254