Skip to content

Commit 81f59cb

Browse files
committed
log: do not pad values longer than 40 characters (ethereum#19592)
* log: Do not pad too long values * log: gofmt
1 parent 7865057 commit 81f59cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

log/format.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import (
1414
)
1515

1616
const (
17-
timeFormat = "2006-01-02T15:04:05-0700"
18-
termTimeFormat = "01-02|15:04:05.000"
19-
floatFormat = 'f'
20-
termMsgJust = 40
17+
timeFormat = "2006-01-02T15:04:05-0700"
18+
termTimeFormat = "01-02|15:04:05.000"
19+
floatFormat = 'f'
20+
termMsgJust = 40
21+
termCtxMaxPadding = 40
2122
)
2223

2324
// 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) {
175176
fieldPaddingLock.RUnlock()
176177

177178
length := utf8.RuneCountInString(v)
178-
if padding < length {
179+
if padding < length && length <= termCtxMaxPadding {
179180
padding = length
180181

181182
fieldPaddingLock.Lock()
@@ -189,7 +190,7 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
189190
buf.WriteByte('=')
190191
}
191192
buf.WriteString(v)
192-
if i < len(ctx)-2 {
193+
if i < len(ctx)-2 && padding > length {
193194
buf.Write(bytes.Repeat([]byte{' '}, padding-length))
194195
}
195196
}

0 commit comments

Comments
 (0)