Commit a5414298 authored by Nikifor Seryakov's avatar Nikifor Seryakov Committed by Péter Szilágyi

log: do not pad values longer than 40 characters (#19592)

* log: Do not pad too long values

* log: gofmt
parent 4cf8505d
......@@ -14,10 +14,11 @@ import (
)
const (
timeFormat = "2006-01-02T15:04:05-0700"
termTimeFormat = "01-02|15:04:05.000"
floatFormat = 'f'
termMsgJust = 40
timeFormat = "2006-01-02T15:04:05-0700"
termTimeFormat = "01-02|15:04:05.000"
floatFormat = 'f'
termMsgJust = 40
termCtxMaxPadding = 40
)
// locationTrims are trimmed for display to avoid unwieldy log lines.
......@@ -175,7 +176,7 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
fieldPaddingLock.RUnlock()
length := utf8.RuneCountInString(v)
if padding < length {
if padding < length && length <= termCtxMaxPadding {
padding = length
fieldPaddingLock.Lock()
......@@ -189,7 +190,7 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
buf.WriteByte('=')
}
buf.WriteString(v)
if i < len(ctx)-2 {
if i < len(ctx)-2 && padding > length {
buf.Write(bytes.Repeat([]byte{' '}, padding-length))
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment