Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriber: impl Clone for EnvFilter #2956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions tracing-subscriber/src/filter/env/mod.rs
Expand Up @@ -204,6 +204,22 @@ pub struct EnvFilter {
regex: bool,
}

/// Creates an [`EnvFilter`] with the same directives as `self`. This does *not* clone any of the
/// dynamic state that [`EnvFilter`] acquires while attached to a subscriber.
impl Clone for EnvFilter {
fn clone(&self) -> EnvFilter {
EnvFilter {
statics: self.statics.clone(),
dynamics: self.dynamics.clone(),
has_dynamics: self.has_dynamics,
by_id: RwLock::new(Default::default()),
by_cs: RwLock::new(Default::default()),
scope: ThreadLocal::new(),
regex: self.regex,
}
}
}

type FieldMap<T> = HashMap<Field, T>;

/// Indicates that an error occurred while parsing a `EnvFilter` from an
Expand Down