tracing/tracing-subscriber
Benjamin Lee 361dd853e3 subscriber: impl Clone for EnvFilter
This is useful when using `EnvFilter` for multiple identical per-layer
filters, as well as with clap and similar libraries that have `Clone`
bounds.

We generally expect users to be cloning an `EnvFilter` before attaching it
to a subscriber, rather than cloning `EnvFilters` that are already
attached. Because of this, we reset all the accumulated dynamic state
when cloning. This means that some spans and callsites might be missed
when an already-attached `EnvFilter` is cloned, but the presence of the
dynamic state mean that detaching and attaching `EnvFilter`s to existing
subscribers (e.g. with `reload`) already doesn't work very well. This
isn't a new class of problem.

There was a previous implementation of this in #2398, that shared the
dynamic state between all cloned filters behind an `Arc`. I chose
not do go for that approach because it causes inconsistencies if the
cloned filters are attached to different subscribers.

Fixes: #2360
2025-03-11 19:15:35 -04:00
..
benches chore: fix new Clippy lints in Rust 1.83.0 (#3164) 2024-11-29 16:51:52 +01:00
src subscriber: impl Clone for EnvFilter 2025-03-11 19:15:35 -04:00
tests chore: fix new Clippy lints in Rust 1.83.0 (#3164) 2024-11-29 16:51:52 +01:00
Cargo.toml chore: clean up warnings on master (#3087) 2024-10-01 12:30:02 -04:00
CHANGELOG.md chore: Fix spelling (#2854) 2024-01-15 19:43:42 +00:00
LICENSE chore: Include the LICENSE in every crate (#842) 2020-07-23 12:23:04 -07:00
README.md chore: bump MSRV to 1.63 (#2793) 2023-11-07 00:07:37 +00:00

Tracing — Structured, application-level diagnostics

tracing-subscriber

Utilities for implementing and composing tracing subscribers.

Crates.io Documentation Documentation (master) MIT licensed Build Status Discord chat maintenance status

Documentation | Chat

Compiler support: requires rustc 1.63+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported version is 1.63. The current Tracing version is not guaranteed to build on Rust versions earlier than the minimum supported version.

Tracing follows the same compiler support policies as the rest of the Tokio project. The current stable Rust compiler and the three most recent minor versions before it will always be supported. For example, if the current stable compiler version is 1.69, the minimum supported version will not be increased past 1.66, three minor versions prior. Increasing the minimum supported compiler version is not considered a semver breaking change as long as doing so complies with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tracing by you, shall be licensed as MIT, without any additional terms or conditions.