From 545fc18f8bc10928db14c94632f8ab132d113646 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 18 Oct 2021 16:32:52 -0700 Subject: [PATCH] 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 --- examples/Cargo.toml | 2 +- tracing-subscriber/Cargo.toml | 4 ++-- tracing-subscriber/benches/reload.rs | 1 + tracing-subscriber/src/lib.rs | 7 ++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 8815831f1e..9f3ab39402 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"] } +tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "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 abe7c88ece..ed469813a3 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", "tracing-log", "json"] +default = ["smallvec", "fmt", "ansi", "tracing-log"] env-filter = ["matchers", "regex", "lazy_static", "tracing"] fmt = ["registry"] ansi = ["fmt", "ansi_term"] @@ -36,7 +36,7 @@ local-time = ["time/local-offset"] [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 71d50888bb..c9becc75de 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 2dfc196220..a9ac89d3bd 100644 --- a/tracing-subscriber/src/lib.rs +++ b/tracing-subscriber/src/lib.rs @@ -23,21 +23,22 @@ //! ## 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. //! - [`local-time`]: Enables local time formatting when using the [`time` //! crate]'s timestamp formatters with the `fmt` subscriber. //! //! ### 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. //! - [`time`]: Enables support for using the [`time` crate] for timestamp //! formatting in the `fmt` subscriber. //! - [`smallvec`]: Causes the `EnvFilter` type to use the `smallvec` crate (rather