ocket8888 commented on code in PR #5696:
URL: https://github.com/apache/trafficcontrol/pull/5696#discussion_r876240812
##########
lib/go-log/log.go:
##########
@@ -76,14 +77,14 @@ func logf(logger *log.Logger, format string, v
...interface{}) {
if logger == nil {
return
}
- logger.Output(stackFrame, time.Now().UTC().Format(timeFormat)+":
"+fmt.Sprintf(format, v...))
+ logger.Output(stackFrame, time.Now().UTC().Format(timeFormat)+":
"+strings.Replace(strings.TrimSpace(fmt.Sprintf(format, v...)), "\n", `\n`,
-1)+"\n")
}
func logln(logger *log.Logger, v ...interface{}) {
if logger == nil {
return
}
- logger.Output(stackFrame, time.Now().UTC().Format(timeFormat)+":
"+fmt.Sprintln(v...))
+ logger.Output(stackFrame, time.Now().UTC().Format(timeFormat)+":
"+strings.Replace(strings.TrimSpace(fmt.Sprintln(v...)), "\n", `\n`, -1)+"\n")
Review Comment:
nit: these `+"\n"`s are unnecessary, because in a call to
`log.Logger.Output`:
> A newline is appended if the last character of s is not already a newline.
Further nit: using `fmt.Sprintln` instead of `fmt.Sprintf` just gives
`strings.TrimSpace` one extra character to delete.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]