Skip to content

Conversation

@ucwong
Copy link
Contributor

@ucwong ucwong commented May 8, 2023

No description provided.

@holiman
Copy link
Contributor

holiman commented May 8, 2023

Diff to test

diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index bac74f2a6e..9c0734e4b8 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -322,6 +322,8 @@ func geth(ctx *cli.Context) error {
        }
 
        prepare(ctx)
+       log.Warn("test", 123, 123, "bar", "baz")
+       return nil
        stack, backend := makeFullNode(ctx)

Master (also this PR before my commit), note {"":123, which is wrong

[user@work go-ethereum]$ go run ./cmd/geth --verbosity 3 --log.format=json  
{"lvl":"info","msg":"Starting Geth on Ethereum mainnet...","t":"2023-05-08T09:00:00.176976284+02:00"}
{"lvl":"info","msg":"Bumping default cache on mainnet","provided":1024,"t":"2023-05-08T09:00:00.177328202+02:00","updated":4096}
{"":123,"LOG15_ERROR":"123 is not a string key","bar":"baz","lvl":"warn","msg":"test","t":"2023-05-08T09:00:00.177366763+02:00"}

This PR:

[user@work go-ethereum]$ go run ./cmd/geth --verbosity 3 --log.format=logfmt
t=2023-05-08T09:08:36+0200 lvl=info msg="Starting Geth on Ethereum mainnet..."
t=2023-05-08T09:08:36+0200 lvl=info msg="Bumping default cache on mainnet"     provided=1024 updated=4096
t=2023-05-08T09:08:36+0200 lvl=warn msg=test                                   LOG15_ERROR=int is not a string key bar=baz

[user@work go-ethereum]$ go run ./cmd/geth --verbosity 3 --log.format=json
{"lvl":"info","msg":"Starting Geth on Ethereum mainnet...","t":"2023-05-08T09:09:10.085519597+02:00"}
{"lvl":"info","msg":"Bumping default cache on mainnet","provided":1024,"t":"2023-05-08T09:09:10.086149846+02:00","updated":4096}
{"LOG15_ERROR":"int is not a string key","bar":"baz","lvl":"warn","msg":"test","t":"2023-05-08T09:09:10.086244948+02:00"}

[user@work go-ethereum]$ go run ./cmd/geth --verbosity 3 --log.format=terminal
INFO [05-08|09:09:21.642] Starting Geth on Ethereum mainnet... 
INFO [05-08|09:09:21.642] Bumping default cache on mainnet         provided=1024 updated=4096
WARN [05-08|09:09:21.642] test                                     LOG15_ERROR=int is not a string key bar=baz

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@holiman holiman changed the title log/format.go : invalid string cast fix log: report error when ctx key is non-string May 8, 2023
@holiman holiman added this to the 1.11.7 milestone May 8, 2023
@holiman holiman merged commit 81d328a into ethereum:master May 8, 2023
shekhirin pushed a commit to shekhirin/go-ethereum that referenced this pull request Jun 6, 2023
* log/format.go : invalid string cast fix

* log: some polish

---------

Co-authored-by: Martin Holst Swende <[email protected]>
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
* log/format.go : invalid string cast fix

* log: some polish

---------

Co-authored-by: Martin Holst Swende <[email protected]>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 15, 2024
* log/format.go : invalid string cast fix

* log: some polish

---------

Co-authored-by: Martin Holst Swende <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants