pub fn capture_tracing_output_at(max_level: Level, f: impl FnOnce()) -> StringExpand description
Like capture_tracing_output, but capturing every level up to and including max_level
(e.g. tracing::Level::DEBUG).
Needed to positively assert a tracing::debug! line fired, or that a tracing::warn!
specifically (as opposed to any level) did not — capture_tracing_output’s fixed INFO
filter makes both assertions vacuous, since a debug! call is invisible there regardless of
whether the code under test emits it correctly.
§Examples
use deps_core::test_util::capture_tracing_output_at;
let output =
capture_tracing_output_at(tracing::Level::DEBUG, || tracing::debug!("quiet detail"));
assert!(output.contains("quiet detail"));