Skip to content

Commit 558cd75

Browse files
feat(env_filter): implement Clone for Filter
One of possible use-cases for Filter would be using it as a CLI argument, so the user can configure the logger without setting any environment variables. Right now it isn't possible to use Filter as a CLI argument in clap, because clap requires all CLI arguments to implement Clone.
1 parent 2ac0e54 commit 558cd75

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

crates/env_filter/src/directive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use log::Level;
22
use log::LevelFilter;
33

4-
#[derive(Debug)]
4+
#[derive(Debug, Clone)]
55
pub(crate) struct Directive {
66
pub(crate) name: Option<String>,
77
pub(crate) level: LevelFilter,

crates/env_filter/src/filter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl fmt::Debug for Builder {
192192
/// Use the [`Builder`] type to parse and construct a `Filter`.
193193
///
194194
/// [`Builder`]: struct.Builder.html
195+
#[derive(Clone)]
195196
pub struct Filter {
196197
directives: Vec<Directive>,
197198
filter: Option<FilterOp>,

crates/env_filter/src/op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
#[derive(Debug)]
3+
#[derive(Debug, Clone)]
44
pub(crate) struct FilterOp {
55
#[cfg(feature = "regex")]
66
inner: regex::Regex,

0 commit comments

Comments
 (0)