Skip to content

Commit 97b9f53

Browse files
committed
wip: restore the tuple impls and tests
1 parent 7b80f17 commit 97b9f53

File tree

4 files changed

+115
-111
lines changed

4 files changed

+115
-111
lines changed

crates/stackable-telemetry/src/tracing/mod.rs

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -617,46 +617,47 @@ mod test {
617617
assert!(trace_guard.otlp_trace_settings.is_disabled());
618618
}
619619

620-
// #[test]
621-
// fn builder_with_console_output_double() {
622-
// let trace_guard = Tracing::builder()
623-
// .service_name("test")
624-
// .with_console_output(("ABC_A", LevelFilter::TRACE))
625-
// .build();
626-
627-
// assert_eq!(
628-
// trace_guard.console_log_settings,
629-
// ConsoleLogSettings {
630-
// common_settings: Settings {
631-
// environment_variable: "ABC_A",
632-
// default_level: LevelFilter::TRACE,
633-
// },
634-
// log_format: Default::default()
635-
// }
636-
// )
637-
// }
638-
639-
// #[rstest]
640-
// #[case(false)]
641-
// #[case(true)]
642-
// fn builder_with_console_output_triple(#[case] enabled: bool) {
643-
// let trace_guard = Tracing::builder()
644-
// .service_name("test")
645-
// .with_console_output(("ABC_A", LevelFilter::TRACE, enabled))
646-
// .build();
647-
648-
// assert_eq!(
649-
// trace_guard.console_log_settings,
650-
// ConsoleLogSettings {
651-
// common_settings: Settings {
652-
// environment_variable: "ABC_A",
653-
// default_level: LevelFilter::TRACE,
654-
// enabled
655-
// },
656-
// log_format: Default::default()
657-
// }
658-
// )
659-
// }
620+
#[test]
621+
fn builder_with_console_output_double() {
622+
let trace_guard = Tracing::builder()
623+
.service_name("test")
624+
.with_console_output(("ABC_A", LevelFilter::TRACE))
625+
.build();
626+
627+
assert_eq!(
628+
trace_guard.console_log_settings,
629+
ConsoleLogSettings::Enabled {
630+
common_settings: Settings {
631+
environment_variable: "ABC_A",
632+
default_level: LevelFilter::TRACE,
633+
},
634+
log_format: Default::default()
635+
}
636+
)
637+
}
638+
639+
#[rstest]
640+
#[case(false)]
641+
#[case(true)]
642+
fn builder_with_console_output_triple(#[case] enabled: bool) {
643+
let trace_guard = Tracing::builder()
644+
.service_name("test")
645+
.with_console_output(("ABC_A", LevelFilter::TRACE, enabled))
646+
.build();
647+
648+
let expected = match enabled {
649+
true => ConsoleLogSettings::Enabled {
650+
common_settings: Settings {
651+
environment_variable: "ABC_A",
652+
default_level: LevelFilter::TRACE,
653+
},
654+
log_format: Default::default(),
655+
},
656+
false => ConsoleLogSettings::Disabled,
657+
};
658+
659+
assert_eq!(trace_guard.console_log_settings, expected)
660+
}
660661

661662
#[test]
662663
fn builder_with_all() {

crates/stackable-telemetry/src/tracing/settings/console_log.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,32 @@ where
105105
}
106106
}
107107

108-
// impl From<(&'static str, LevelFilter)> for ConsoleLogSettings {
109-
// fn from(value: (&'static str, LevelFilter)) -> Self {
110-
// Self {
111-
// common_settings: Settings {
112-
// environment_variable: value.0,
113-
// default_level: value.1,
114-
// enabled: true,
115-
// },
116-
// ..Default::default()
117-
// }
118-
// }
119-
// }
120-
121-
// impl From<(&'static str, LevelFilter, bool)> for ConsoleLogSettings {
122-
// fn from(value: (&'static str, LevelFilter, bool)) -> Self {
123-
// Self {
124-
// common_settings: Settings {
125-
// environment_variable: value.0,
126-
// default_level: value.1,
127-
// enabled: value.2,
128-
// },
129-
// ..Default::default()
130-
// }
131-
// }
132-
// }
108+
impl From<(&'static str, LevelFilter)> for ConsoleLogSettings {
109+
fn from(value: (&'static str, LevelFilter)) -> Self {
110+
Self::Enabled {
111+
common_settings: Settings {
112+
environment_variable: value.0,
113+
default_level: value.1,
114+
},
115+
log_format: Default::default(),
116+
}
117+
}
118+
}
119+
120+
impl From<(&'static str, LevelFilter, bool)> for ConsoleLogSettings {
121+
fn from(value: (&'static str, LevelFilter, bool)) -> Self {
122+
match value.2 {
123+
true => Self::Enabled {
124+
common_settings: Settings {
125+
environment_variable: value.0,
126+
default_level: value.1,
127+
},
128+
log_format: Default::default(),
129+
},
130+
false => Self::Disabled,
131+
}
132+
}
133+
}
133134

134135
#[cfg(test)]
135136
mod test {

crates/stackable-telemetry/src/tracing/settings/otlp_log.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,30 @@ where
6666
}
6767
}
6868

69-
// impl From<(&'static str, LevelFilter)> for OtlpLogSettings {
70-
// fn from(value: (&'static str, LevelFilter)) -> Self {
71-
// Self {
72-
// common_settings: Settings {
73-
// environment_variable: value.0,
74-
// default_level: value.1,
75-
// enabled: true,
76-
// },
77-
// }
78-
// }
79-
// }
80-
81-
// impl From<(&'static str, LevelFilter, bool)> for OtlpLogSettings {
82-
// fn from(value: (&'static str, LevelFilter, bool)) -> Self {
83-
// Self {
84-
// common_settings: Settings {
85-
// environment_variable: value.0,
86-
// default_level: value.1,
87-
// enabled: value.2,
88-
// },
89-
// }
90-
// }
91-
// }
69+
impl From<(&'static str, LevelFilter)> for OtlpLogSettings {
70+
fn from(value: (&'static str, LevelFilter)) -> Self {
71+
Self::Enabled {
72+
common_settings: Settings {
73+
environment_variable: value.0,
74+
default_level: value.1,
75+
},
76+
}
77+
}
78+
}
79+
80+
impl From<(&'static str, LevelFilter, bool)> for OtlpLogSettings {
81+
fn from(value: (&'static str, LevelFilter, bool)) -> Self {
82+
match value.2 {
83+
true => Self::Enabled {
84+
common_settings: Settings {
85+
environment_variable: value.0,
86+
default_level: value.1,
87+
},
88+
},
89+
false => Self::Disabled,
90+
}
91+
}
92+
}
9293

9394
#[cfg(test)]
9495
mod test {

crates/stackable-telemetry/src/tracing/settings/otlp_trace.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,30 @@ where
6666
}
6767
}
6868

69-
// impl From<(&'static str, LevelFilter)> for OtlpTraceSettings {
70-
// fn from(value: (&'static str, LevelFilter)) -> Self {
71-
// Self {
72-
// common_settings: Settings {
73-
// environment_variable: value.0,
74-
// default_level: value.1,
75-
// enabled: true,
76-
// },
77-
// }
78-
// }
79-
// }
80-
81-
// impl From<(&'static str, LevelFilter, bool)> for OtlpTraceSettings {
82-
// fn from(value: (&'static str, LevelFilter, bool)) -> Self {
83-
// Self {
84-
// common_settings: Settings {
85-
// environment_variable: value.0,
86-
// default_level: value.1,
87-
// enabled: value.2,
88-
// },
89-
// }
90-
// }
91-
// }
69+
impl From<(&'static str, LevelFilter)> for OtlpTraceSettings {
70+
fn from(value: (&'static str, LevelFilter)) -> Self {
71+
Self::Enabled {
72+
common_settings: Settings {
73+
environment_variable: value.0,
74+
default_level: value.1,
75+
},
76+
}
77+
}
78+
}
79+
80+
impl From<(&'static str, LevelFilter, bool)> for OtlpTraceSettings {
81+
fn from(value: (&'static str, LevelFilter, bool)) -> Self {
82+
match value.2 {
83+
true => Self::Enabled {
84+
common_settings: Settings {
85+
environment_variable: value.0,
86+
default_level: value.1,
87+
},
88+
},
89+
false => Self::Disabled,
90+
}
91+
}
92+
}
9293

9394
#[cfg(test)]
9495
mod test {

0 commit comments

Comments
 (0)