1
0
Fork 0
forked from forks/go-ethereum
go-ethereum-modded-tocallarg/internal
jwasinger f64aa6eaf7
internal/testlog: fix log output from sub-loggers (#31539)
When we instantiate a sub-logger via
`go-ethereum/internal/testlog/logger.With`, we copy the reference to the
`bufHandler` from the parent logger. However, internally,
`go-ethereum/internal/testlog/logger.With` calls `log/slog/Logger.With`
which creates a new handler instance (via
`internal/bufHandler.WithAttrs`).

This PR modifies sub-logger instantiation to use the newly-instantiated
handler, instead of copying the reference from the parent instance. The
type cast from `slog.Handler` to `*bufHandler` in
`internal/testlog/Logger.With` is safe here because a
`internal/testlog/Logger` can only be instantiated with a `*bufHandler`
as the underlying handler type.

Note, that I've also removed a pre-existing method that broke the above
assumption. However, this method is not used in our codebase.

I'm not sure if the assumption holds for forks of geth (e.g. optimism
has modified the testlogger somewhat allowing test loggers to accept
arbitrary handler types), but it seems okay to break API compatibility
given that this is in the `internal` package.

closes https://github.com/ethereum/go-ethereum/issues/31533
2025-04-10 18:21:32 +02:00
..
blocktest
build
cmdtest
debug
era internal/era: random access to header and receipts (#31544) 2025-04-04 06:07:46 -06:00
ethapi eth: fix calls to HistoryPruningCutoff (#31552) 2025-04-03 15:44:07 +02:00
flags
guide all: fix typos in docs and comments (#31548) 2025-04-02 13:52:40 -06:00
jsre
reexec
shutdowncheck
syncx
testlog internal/testlog: fix log output from sub-loggers (#31539) 2025-04-10 18:21:32 +02:00
testrand
utesting
version
web3ext