-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
make sure no trailing spaces #100
Conversation
I think Thanks for working on this! |
or maybe code like this, just remove one possible space, if byts[len(byts)-1] == ' ' {
byts = byts[:len(byts)-1]
} |
I have another TestColorPrint which tests how many spaces can the printColored func make: there could be many of them:
So it's better to run in a loop: for byts[len(byts)-1] == ' ' {
byts = byts[:len(byts)-1]
} or call bytes.TrimRightFunc: byts = bytes.TrimRightFunc(byts, unicode.IsSpace) |
printKeyValue is working similar like printColored, not using any fields of TextFormatter, should be a util func instead of a method of TextFormatter. Signed-off-by: Derek Che <drc@yahoo-inc.com>
Signed-off-by: Derek Che <drc@yahoo-inc.com>
This changed printColored and printKeyValue to print in same way with prefix space instead of trailing space, to make it easier to slice out when returning in Format; The test cases are to make sure msg formartting doesn't include leading or trailing spaces; Closes sirupsen#99 Signed-off-by: Derek Che <drc@yahoo-inc.com>
@sirupsen do you have an update on this? I'm looking into this because docker code is referencing here, and every docker ci has log lines ends a space. |
Can you squash? Otherwise looks good |
this was initially in a single patch but I have split it into 3 separate to make each one's intention be clear; now to squash them is surely easy, but why does here prefer a squashed single commit? or do you have any worries on number of commits? |
Closes #99 text log should not have trailing spaces.
just reorganize the patch into 3 commits:
03377c6 rename f.appendKeyValue to printKeyValue
a243bba share common calling path in printKeyValue
dcbe8d6 make sure no leading or trailing spaces
In benchmark testing, it increased ~300 ns/op in SmallTextFormatter,
that should be due to the extra slice operation [1:];
in LargeTextFormatter it reduced ~700 ns/op;
Signed-off-by: Derek Che drc@yahoo-inc.com