Repository navigation
fix(log): port upstream glog handler rewrite #33111 #35176, close #2876 - #2884
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
a5c695f to
0482577
Compare
06d4096 to
6ed2440
Compare
743b2ea to
ea20f37
Compare
…35176, close XinFinOrg#2876 The old RWMutex + siteCache GlogHandler carried two behavioral gaps inherited from upstream: --vmodule could not downgrade log levels below the global verbosity (the global fast-track let everything through), and child loggers created via WithAttrs kept a snapshot of the level and patterns, so later Verbosity/Vmodule changes on the parent never reached them. Port go-ethereum's rewrite (ethereum#33111): GlogHandler now holds an atomic.Pointer to an immutable glogConfig (patterns, level and a sync.Map callsite cache), and WithAttrs returns a glogWithAttrs wrapper that delegates back to the parent handler, fixing both gaps. The two upstream regression tests (TestLoggingWithVmoduleDowngrade, TestWithAttrsVerbosityChange) come along, plus the out.String() fix in TestJSONHandler. The reflect.Ptr -> reflect.Pointer rename from ethereum#35176 is already in the tree, so log/format.go stays untouched here. On top of the two upstream tests, TestLoggingCallsiteCacheInvalidation drives two records through the same callsite, tightening the level via Vmodule in one subtest and via Verbosity in the other, which is what pins the per-config replacement of the callsite cache (the upstream tests log from different PCs and never hit it). Deliberately kept divergent from upstream: strings.SplitSeq in Vmodule (this repo replaced strings.Split repo-wide in XinFinOrg#1698), and the package level Enabled() helper in root.go (used by p2p/discover), so root.go is left untouched. Ref: go-ethereum ethereum#33111 (d07a946) Ref: go-ethereum ethereum#35176 (7c9032d) Close XinFinOrg#2876
ea20f37 to
cdb7dd8
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The logging-handler rewrite has no active review issues.
No open issues 🎉
What changed in this PR
Ports the upstream go-ethereum logging-handler rewrite to address the remaining logging divergence tracked in #2876, while preserving repository-specific behavior and public method signatures.
Changes:
- Allows
Vmodulerules to reduce verbosity below the global setting. - Shares configuration with child loggers so they follow runtime verbosity and module-filter changes.
- Adds regression tests for filtering, child-log configuration updates, and callsite-cache invalidation, and corrects JSON test diagnostic formatting.
| File | Description |
|---|---|
log/logger_test.go |
Adds logging regression tests and fixes JSON failure-output formatting. |
log/handler_glog.go |
Replaces configuration snapshots with shared atomic configuration, per-configuration caching, and child-handler wrappers. |
Review effort: Balanced
Summary
Port go-ethereum's
log/rewrite to close out the remaining divergence inventory of #2876 (handler.gowas already synced by #2837).log/handler_glog.go— full rewrite from upstream log: allow –vmodule to downgrade log levels ethereum/go-ethereum#33111;--vmodulecan now downgrade below the global verbosity, and child loggers follow laterVerbosity/Vmodulechanges on the parent.log/logger_test.go— upstream regression testsTestLoggingWithVmoduleDowngrade,TestWithAttrsVerbosityChange, plus theout→out.String()fix inTestJSONHandler, and one repo-localTestLoggingCallsiteCacheInvalidationthat drives two records through the same callsite, tightening the level via vmodule in one subtest and via verbosity in the other, to pin the per-config replacement of the callsite cache (the upstream tests log from different PCs and never hit it).log/format.go— untouched here: thereflect.Ptr→reflect.Pointerrename from all: change reflect.Ptr to reflect.Pointer ethereum/go-ethereum#35176 is already in the tree (log/format.go:126).Deliberately kept divergent from upstream (see commit body):
strings.SplitSeqinVmodule— this repo replacedstrings.Splitrepo-wide in all: replacestrings.Splitwith more efficientstrings.SplitSeq#1698.root.gountouched — its package-levelEnabled()helper (not in upstream) is used byp2p/discover/table.go.handler_glog.gois byte-identical to upstream master (2006f0836b) except the twoSplitSeqlines, andlogger_test.gomatches upstream apart from the addedTestLoggingCallsiteCacheInvalidation. The follow-ups after ethereum#33111 (ethereum#35055, ethereum#35074, ethereum#35176, ethereum#35141) are all in the tree already.Behaviour changes
--vmodulemay now downgrade: a rule whose level is above the global verbosity filters that file's records instead of only raising them.--verbosityat runtime produces more output from loggers that used to stay frozen at their creation-time level — per-peer loggers inp2p/discoveramong them — so log volume can go up after upgrading.Evidence
Before (new tests on old handler,
dev-upgrade):After (this branch):
diff -uagainst go-ethereum master:log/logger_test.goonly addsTestLoggingCallsiteCacheInvalidation,log/handler_glog.goonly the twoSplitSeqlines.Checks run:
go test -count=1 ./log/...green,make allexit 0,make tidyclean, golangci-lint--new-from-rev0 issues, gofmt/goimports clean.Merge Danger
Door: two-way
Blast Radius:
logpackage internalsBehavioral notes for reviewers:
GlogHandler.Handlenow checks the vmodule callsite cache before the global fast-track (this is the fix), andWithAttrsno longer copies config state. All external callers (internal/debug,cmd/bootnode,internal/debug/api.go) only useNewGlogHandler/Verbosity/Vmodule, whose signatures are unchanged.Ref: go-ethereum ethereum#33111 (d07a946)
Ref: go-ethereum ethereum#35176 (7c9032d)
Close #2876