go-ethereum/log
Daniel Liu 915c71f2c4
log: fix SetDefault for custom loggers #31368 (#1511)
Currently, even though it takes in a `Logger` interface,
`log.SetDefualt` enforces that the concrete type of the provided logger
is `*logger` because:
1. in `init` `root.Store` is called with a `*logger`
2. `atomic.Value` panics if the concrete type provided in `Store` is not
consistent across calls.
([ref](https://pkg.go.dev/sync/atomic#Value.Store))

> All calls to Store for a given Value must use values of the same
concrete type.

This PR changes to use `sync.RWMutex` and adds a test that panics on
`master`.

Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
2025-09-17 08:28:13 +08:00
..
format.go log: remove unused parameter #30432 (#1509) 2025-09-17 08:26:34 +08:00
format_test.go slog: faster and less memory-consumption (#28621) 2024-11-15 10:02:42 +08:00
handler.go log: default JSON log handler should log all verbosity levels (#29471) 2024-11-15 10:02:42 +08:00
handler_glog.go log: fix some functions comments (#29907) 2024-11-15 10:02:43 +08:00
logger.go log: fix some functions comments (#29907) 2024-11-15 10:02:43 +08:00
logger_test.go log: fix issues with benchmarks (#30667) 2024-11-15 10:02:43 +08:00
root.go log: fix SetDefault for custom loggers #31368 (#1511) 2025-09-17 08:28:13 +08:00
root_test.go log: fix SetDefault for custom loggers #31368 (#1511) 2025-09-17 08:28:13 +08:00