-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/geth: more testcases for logging #28501
Conversation
This adds more edgecases around logging, particularly around handling of different types of nil-values as concrete types and within interfaces. Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in, but not actively used by any testcase at the moment.
{"lvl":"info","msg":"nil-custom-struct","res":"\u003cnil\u003e","t":"2023-11-09T08:33:19.465638888+01:00"} | ||
{"lvl":"info","msg":"raw nil","res":"\u003cnil\u003e","t":"2023-11-09T08:33:19.465673664+01:00"} | ||
{"lvl":"info","msg":"(*uint64)(nil)","res":"\u003cnil\u003e","t":"2023-11-09T08:33:19.465700264+01:00"} | ||
{"level":"level","lvl":"lvl","msg":"msg","t":"t","time":"time"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @jwasinger our old logger is broken: it simply overwrites the 'native' t
with whatever the caller specified. So there's no need to make the new one behave better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay. slog text/json handlers produce a duplicate field instead of overwriting in this case.
t=2023-11-09T08:26:52+0100 lvl=info msg=nil-custom-struct res=<nil> | ||
t=2023-11-09T08:26:52+0100 lvl=info msg="raw nil" res=nil | ||
t=2023-11-09T08:26:52+0100 lvl=info msg=(*uint64)(nil) res=<nil> | ||
t=2023-11-09T08:30:19+0100 lvl=info msg="Using keys 't', 'lvl', 'time', 'level' and 'msg'" t=t time=time lvl=lvl level=level msg=msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old logfmt
handler actually does handle multiple keys. Oh well. Still a programming-error, IMO
INFO [XX-XX|XX:XX:XX.XXX] error(nil) res=nil | ||
INFO [XX-XX|XX:XX:XX.XXX] nil-concrete-error res= | ||
INFO [XX-XX|XX:XX:XX.XXX] nil-custom-struct res=<nil> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three flavours of expressing nil
. Sheesh
* cmd/geth: more testcases for logging This adds more edgecases around logging, particularly around handling of different types of nil-values as concrete types and within interfaces. Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in, but not actively used by any testcase at the moment. * cmd/geth/testdata: remove timestamps
This reverts commit 49a09d7.
This reverts commit 49a09d7.
* cmd/geth: more testcases for logging This adds more edgecases around logging, particularly around handling of different types of nil-values as concrete types and within interfaces. Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in, but not actively used by any testcase at the moment. * cmd/geth/testdata: remove timestamps
* cmd/geth: more testcases for logging This adds more edgecases around logging, particularly around handling of different types of nil-values as concrete types and within interfaces. Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in, but not actively used by any testcase at the moment. * cmd/geth/testdata: remove timestamps
This adds more edgecases around logging, particularly around handling of different types of nil-values as concrete types and within interfaces.
Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in, but not actively used by any testcase at the moment.
I also removed the timestamps from the output, to remove some of the 'false postives' when we make any changes to it.
This PR is in preparation of #28187