Skip to content

Commit

Permalink
subscriber: reduce default features
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hawkw committed Oct 18, 2021
1 parent 202632c commit c02fdaf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tracing-core = { path = "../tracing-core", version = "0.2"}
tracing-error = { path = "../tracing-error" }
tracing-flame = { path = "../tracing-flame" }
tracing-tower = { version = "0.1.0", path = "../tracing-tower" }
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "chrono"] }
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "chrono", "env-filter"] }
tracing-futures = { version = "0.3", path = "../tracing-futures", features = ["futures-01"] }
tracing-attributes = { path = "../tracing-attributes", version = "0.2"}
tracing-log = { path = "../tracing-log", version = "0.2", features = ["env_logger"] }
Expand Down
4 changes: 2 additions & 2 deletions tracing-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ keywords = ["logging", "tracing", "metrics", "subscriber"]

[features]

default = ["env-filter", "smallvec", "fmt", "ansi", "chrono", "tracing-log", "json"]
default = ["smallvec", "fmt", "ansi", "tracing-log"]
env-filter = ["matchers", "regex", "lazy_static", "tracing"]
fmt = ["registry"]
ansi = ["fmt", "ansi_term"]
Expand All @@ -33,7 +33,7 @@ json = ["tracing-serde", "serde", "serde_json"]
[dependencies]
tracing-core = { path = "../tracing-core", version = "0.2" }

# only required by the filter feature
# only required by the `env-filter` feature
tracing = { optional = true, path = "../tracing", version = "0.2", default-features = false, features = ["std"] }
matchers = { optional = true, version = "0.1.0" }
regex = { optional = true, version = "1", default-features = false, features = ["std"] }
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/benches/reload.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "env-filter")]
use criterion::{criterion_group, criterion_main, Criterion};
use tracing_subscriber::{
filter::LevelFilter,
Expand Down
8 changes: 4 additions & 4 deletions tracing-subscriber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
//! ## Feature Flags
//!
//! - `env-filter`: Enables the [`EnvFilter`] type, which implements filtering
//! similar to the [`env_logger` crate]. Enabled by default.
//! similar to the [`env_logger` crate].
//! - `fmt`: Enables the [`fmt`] module, which provides a subscriber
//! implementation for printing formatted representations of trace events.
//! Enabled by default.
//! - `ansi`: Enables `fmt` support for ANSI terminal colors. Enabled by
//! default.
//! - `registry`: enables the [`registry`] module. Enabled by default.
//! - `json`: Enables `fmt` support for JSON output. In JSON output, the ANSI feature does nothing.
//! - `json`: Enables `fmt` support for JSON output. In JSON output, the ANSI
//! feature does nothing.
//!
//! ### Optional Dependencies
//!
//! - [`tracing-log`]: Enables better formatting for events emitted by `log`
//! macros in the `fmt` subscriber. On by default.
//! macros in the `fmt` subscriber. Enabled by default.
//! - [`chrono`]: Enables human-readable time formatting in the `fmt` subscriber.
//! Enabled by default.
//! - [`smallvec`]: Causes the `EnvFilter` type to use the `smallvec` crate (rather
//! than `Vec`) as a performance optimization. Enabled by default.
//! - [`parking_lot`]: Use the `parking_lot` crate's `RwLock` implementation
Expand Down

0 comments on commit c02fdaf

Please sign in to comment.