]> git.proxmox.com Git - rustc.git/blame - vendor/chalk-solve-0.25.0/src/logging.rs
New upstream version 1.48.0+dfsg1
[rustc.git] / vendor / chalk-solve-0.25.0 / src / logging.rs
CommitLineData
1b1a35ee
XL
1/// Run an action with a tracing log subscriber. The logging level is loaded
2/// from `CHALK_DEBUG`.
3#[cfg(feature = "tracing-full")]
4pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
5 use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
6 use tracing_tree::HierarchicalLayer;
7 let filter = EnvFilter::from_env("CHALK_DEBUG");
8 let subscriber = Registry::default()
9 .with(filter)
10 .with(HierarchicalLayer::new(2));
11 tracing::subscriber::with_default(subscriber, action)
12}
13
14/// Run an action with a tracing log subscriber. The logging level is loaded
15/// from `CHALK_DEBUG`.
16#[cfg(not(feature = "tracing-full"))]
17pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
18 action()
19}