aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikifor Seryakov <nikandfor@gmail.com>2019-05-20 21:26:29 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-20 21:26:29 +0800
commita54142987c913f47de4dcec9d9b2dc4bb3654f22 (patch)
treed42017388d669073327c49ac54b2e82bbd3febd3
parent4cf8505d22f1f323a6af0ac8f33a24aa9e242a91 (diff)
downloadgo-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar.gz
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar.bz2
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar.lz
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar.xz
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.tar.zst
go-tangerine-a54142987c913f47de4dcec9d9b2dc4bb3654f22.zip
log: do not pad values longer than 40 characters (#19592)
* log: Do not pad too long values * log: gofmt
-rw-r--r--log/format.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/log/format.go b/log/format.go
index 7902b296e..a1b5dac62 100644
--- a/log/format.go
+++ b/log/format.go
@@ -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))
}
}