From c02fdafddbeea86fceafbb5878bb74264ab25bd1 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 18 Oct 2021 11:16:43 -0700 Subject: [PATCH] subscriber: reduce default features 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 --- examples/Cargo.toml | 2 +- tracing-subscriber/Cargo.toml | 4 ++-- tracing-subscriber/benches/reload.rs | 1 + tracing-subscriber/src/lib.rs | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 0cef263d96..48e4162e41 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -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"] } diff --git a/tracing-subscriber/Cargo.toml b/tracing-subscriber/Cargo.toml index db9bf35797..b88020579f 100644 --- a/tracing-subscriber/Cargo.toml +++ b/tracing-subscriber/Cargo.toml @@ -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"] @@ -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"] } diff --git a/tracing-subscriber/benches/reload.rs b/tracing-subscriber/benches/reload.rs index ae060f6160..5a4f92df6b 100644 --- a/tracing-subscriber/benches/reload.rs +++ b/tracing-subscriber/benches/reload.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "env-filter")] use criterion::{criterion_group, criterion_main, Criterion}; use tracing_subscriber::{ filter::LevelFilter, diff --git a/tracing-subscriber/src/lib.rs b/tracing-subscriber/src/lib.rs index 1129f233ef..30486a5b09 100644 --- a/tracing-subscriber/src/lib.rs +++ b/tracing-subscriber/src/lib.rs @@ -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