Use go-ethereum with fixed logger

This commit is contained in:
Dmitry 2019-03-06 09:43:07 +02:00 committed by Dmitry Shulyak
parent 44ee59b4eb
commit b2f02d0dbe
3 changed files with 51 additions and 26 deletions

4
Gopkg.lock generated
View File

@ -99,7 +99,7 @@
revision = "935e0e8a636ca4ba70b713f3e38a19e1b77739e8"
[[projects]]
digest = "1:e4000f701f06027e58e6ecb5e1b9cebd1d31ed32187d0c036ca0f9bfba580c32"
digest = "1:f3a1decfa9d9febe78b7fa707c21d4ce11e69bebb84b42f4c06486668acc00be"
name = "github.com/ethereum/go-ethereum"
packages = [
".",
@ -168,7 +168,7 @@
"trie",
]
pruneopts = "T"
revision = "8bca0916296164f0c2e6fd178b7735aa8af581f5"
revision = "fbf6423d2e83512382fbf640d72ca7822b0d3590"
source = "github.com/status-im/go-ethereum"
version = "v1.8.21"

View File

@ -0,0 +1,49 @@
diff --git a/log/format.go b/log/format.go
index 7902b296e..5a028263f 100644
--- a/log/format.go
+++ b/log/format.go
@@ -43,13 +43,6 @@ var locationEnabled uint32
// padded to to aid in alignment.
var locationLength uint32
-// fieldPadding is a global map with maximum field value lengths seen until now
-// to allow padding log contexts in a bit smarter way.
-var fieldPadding = make(map[string]int)
-
-// fieldPaddingLock is a global mutex protecting the field padding map.
-var fieldPaddingLock sync.RWMutex
-
type Format interface {
Format(r *Record) []byte
}
@@ -168,20 +161,6 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
if !ok {
k, v = errorKey, formatLogfmtValue(k, term)
}
-
- // XXX: we should probably check that all of your key bytes aren't invalid
- fieldPaddingLock.RLock()
- padding := fieldPadding[k]
- fieldPaddingLock.RUnlock()
-
- length := utf8.RuneCountInString(v)
- if padding < length {
- padding = length
-
- fieldPaddingLock.Lock()
- fieldPadding[k] = padding
- fieldPaddingLock.Unlock()
- }
if color > 0 {
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=", color, k)
} else {
@@ -189,9 +168,6 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
buf.WriteByte('=')
}
buf.WriteString(v)
- if i < len(ctx)-2 {
- buf.Write(bytes.Repeat([]byte{' '}, padding-length))
- }
}
buf.WriteByte('\n')
}

View File

@ -43,13 +43,6 @@ var locationEnabled uint32
// padded to to aid in alignment.
var locationLength uint32
// fieldPadding is a global map with maximum field value lengths seen until now
// to allow padding log contexts in a bit smarter way.
var fieldPadding = make(map[string]int)
// fieldPaddingLock is a global mutex protecting the field padding map.
var fieldPaddingLock sync.RWMutex
type Format interface {
Format(r *Record) []byte
}
@ -168,20 +161,6 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
if !ok {
k, v = errorKey, formatLogfmtValue(k, term)
}
// XXX: we should probably check that all of your key bytes aren't invalid
fieldPaddingLock.RLock()
padding := fieldPadding[k]
fieldPaddingLock.RUnlock()
length := utf8.RuneCountInString(v)
if padding < length {
padding = length
fieldPaddingLock.Lock()
fieldPadding[k] = padding
fieldPaddingLock.Unlock()
}
if color > 0 {
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=", color, k)
} else {
@ -189,9 +168,6 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
buf.WriteByte('=')
}
buf.WriteString(v)
if i < len(ctx)-2 {
buf.Write(bytes.Repeat([]byte{' '}, padding-length))
}
}
buf.WriteByte('\n')
}