Skip to content

Commit 545fc18

Browse files
authored
subscriber: reduce default features (#1647)
This changes `tracing-subscriber` so that the `env-filter`, `json`, and `chrono` features are not enabled by default, and instead require users to opt in. This should significantly reduce the default dependency footprint. Of course, this is a breaking change, and therefore will be part of `tracing-subscriber` v0.3. Fixes #1258 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
1 parent 6614b2f commit 545fc18

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tracing-core = { path = "../tracing-core", version = "0.2"}
1515
tracing-error = { path = "../tracing-error" }
1616
tracing-flame = { path = "../tracing-flame" }
1717
tracing-tower = { version = "0.1.0", path = "../tracing-tower" }
18-
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json"] }
18+
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "env-filter"] }
1919
tracing-futures = { version = "0.3", path = "../tracing-futures", features = ["futures-01"] }
2020
tracing-attributes = { path = "../tracing-attributes", version = "0.2"}
2121
tracing-log = { path = "../tracing-log", version = "0.2", features = ["env_logger"] }

tracing-subscriber/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ keywords = ["logging", "tracing", "metrics", "subscriber"]
2323

2424
[features]
2525

26-
default = ["env-filter", "smallvec", "fmt", "ansi", "tracing-log", "json"]
26+
default = ["smallvec", "fmt", "ansi", "tracing-log"]
2727
env-filter = ["matchers", "regex", "lazy_static", "tracing"]
2828
fmt = ["registry"]
2929
ansi = ["fmt", "ansi_term"]
@@ -36,7 +36,7 @@ local-time = ["time/local-offset"]
3636
[dependencies]
3737
tracing-core = { path = "../tracing-core", version = "0.2" }
3838

39-
# only required by the filter feature
39+
# only required by the `env-filter` feature
4040
tracing = { optional = true, path = "../tracing", version = "0.2", default-features = false, features = ["std"] }
4141
matchers = { optional = true, version = "0.1.0" }
4242
regex = { optional = true, version = "1", default-features = false, features = ["std"] }

tracing-subscriber/benches/reload.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "env-filter")]
12
use criterion::{criterion_group, criterion_main, Criterion};
23
use tracing_subscriber::{
34
filter::LevelFilter,

tracing-subscriber/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@
2323
//! ## Feature Flags
2424
//!
2525
//! - `env-filter`: Enables the [`EnvFilter`] type, which implements filtering
26-
//! similar to the [`env_logger` crate]. Enabled by default.
26+
//! similar to the [`env_logger` crate].
2727
//! - `fmt`: Enables the [`fmt`] module, which provides a subscriber
2828
//! implementation for printing formatted representations of trace events.
2929
//! Enabled by default.
3030
//! - `ansi`: Enables `fmt` support for ANSI terminal colors. Enabled by
3131
//! default.
3232
//! - `registry`: enables the [`registry`] module. Enabled by default.
33-
//! - `json`: Enables `fmt` support for JSON output. In JSON output, the ANSI feature does nothing.
33+
//! - `json`: Enables `fmt` support for JSON output. In JSON output, the ANSI
34+
//! feature does nothing.
3435
//! - [`local-time`]: Enables local time formatting when using the [`time`
3536
//! crate]'s timestamp formatters with the `fmt` subscriber.
3637
//!
3738
//! ### Optional Dependencies
3839
//!
3940
//! - [`tracing-log`]: Enables better formatting for events emitted by `log`
40-
//! macros in the `fmt` subscriber. On by default.
41+
//! macros in the `fmt` subscriber. Enabled by default.
4142
//! - [`time`]: Enables support for using the [`time` crate] for timestamp
4243
//! formatting in the `fmt` subscriber.
4344
//! - [`smallvec`]: Causes the `EnvFilter` type to use the `smallvec` crate (rather

0 commit comments

Comments
 (0)