cloudflare / cloudflare/foundations
Add log setting to panic when field is overwritten
Open
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 133
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 11
Description
When log fields are added in a loop without forking the logger, it is easy to create very long logger chains and hit stack overflows on drop. We have some workarounds in place already to help detect such cases (#47 and #189), but a key insight is that often _the same_ key will be set many times.
A new `LoggingSetting` that makes foundations panic when a key is overwritten would help detect such cases. Sometimes overriding a key is intentional, so we also need an escape hatch in the `log::add_fields` macro that explicitly allows overwriting existing keys.
Contributor guide
Assessment
This issue has not been assessed yet.