Skip to content

Commit 1368b4d

Browse files
committed
Feature gate tracing-subscriber / tracing-tree
1 parent 2bd06ea commit 1368b4d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

chalk-solve/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ ena = "0.14.0"
1414
itertools = "0.9.0"
1515
petgraph = "0.5.0"
1616
tracing = "0.1"
17-
tracing-subscriber = "0.2"
18-
tracing-tree = "0.1.1"
17+
tracing-subscriber = { version = "0.2", optional = true }
18+
tracing-tree = { version = "0.1.1", optional = true }
1919
rustc-hash = { version = "1.0.0" }
2020

2121
chalk-derive = { version = "0.16.0-dev.0", path = "../chalk-derive" }
@@ -26,7 +26,8 @@ chalk-ir = { version = "0.16.0-dev.0", path = "../chalk-ir" }
2626
chalk-integration = { path = "../chalk-integration" }
2727

2828
[features]
29-
default = ["slg-solver", "recursive-solver"]
29+
default = ["slg-solver", "recursive-solver", "tracing-full"]
3030

3131
slg-solver = ["chalk-engine"]
3232
recursive-solver = []
33+
tracing-full = ["tracing-subscriber", "tracing-tree"]

chalk-solve/src/logging.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
2-
use tracing_tree::HierarchicalLayer;
3-
41
/// Run an action with a tracing log subscriber. The logging level is loaded
52
/// from `CHALK_DEBUG`.
3+
#[cfg(feature = "tracing-full")]
64
pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
5+
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
6+
use tracing_tree::HierarchicalLayer;
77
let filter = EnvFilter::from_env("CHALK_DEBUG");
88
let subscriber = Registry::default()
99
.with(filter)
1010
.with(HierarchicalLayer::new(2));
1111
tracing::subscriber::with_default(subscriber, action)
1212
}
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"))]
17+
pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
18+
action()
19+
}

0 commit comments

Comments
 (0)