Skip to content

Commit

Permalink
tracing: Make tracing-attributes (and syn) optional (#603)
Browse files Browse the repository at this point in the history
This allows consumers to use the convenience of `tracing`
without having to pull in the `syn` crate.
  • Loading branch information
jonhoo authored Feb 26, 2020
1 parent d533f90 commit 7e72e1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased

### Changed

- The `instrument` attribute was placed under an on-by-default feature
flag (#603)

# 0.1.12 (January 11, 2019)

### Added
Expand Down
5 changes: 3 additions & 2 deletions tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ edition = "2018"
[dependencies]
tracing-core = { path = "../tracing-core", version = "0.1.10", default-features = false }
log = { version = "0.4", optional = true }
tracing-attributes = { path = "../tracing-attributes", version = "0.1.6"}
tracing-attributes = { path = "../tracing-attributes", version = "0.1.6", optional = true }
cfg-if = "0.1.10"

[dev-dependencies]
Expand All @@ -38,7 +38,7 @@ criterion = { version = "0.3", default_features = false }
log = "0.4"

[features]
default = ["std"]
default = ["std", "attributes"]

max_level_off = []
max_level_error = []
Expand All @@ -59,6 +59,7 @@ async-await = []

std = ["tracing-core/std"]
log-always = ["log"]
attributes = ["tracing-attributes"]

[[bench]]
name = "subscriber"
Expand Down
9 changes: 8 additions & 1 deletion tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
//! fields using `fmt::Debug`.
//!
//! For example:
//! ```
//! ```ignore
//! # // this doctest is ignored because we don't have a way to say
//! # // that it should only be run with cfg(feature = "attributes")
//! use tracing::{Level, event, instrument};
//!
//! #[instrument]
Expand Down Expand Up @@ -654,6 +656,9 @@
//! applications which intend to collect traces and logs separately; if an
//! adapter is used to convert `log` records into `tracing` events, this will
//! cause duplicate events to occur.
//! * `attributes`: Includes support for the `#[instrument]` attribute.
//! This is on by default, but does bring in the `syn` crate as a dependency,
//! which may add to the compile time of crates that do not already use it.
//! * `std`: Depend on the Rust standard library (enabled by default).
//!
//! `no_std` users may disable this feature with `default-features = false`:
Expand Down Expand Up @@ -753,6 +758,8 @@ pub use self::{

#[doc(inline)]
pub use self::span::Span;
#[cfg(feature = "attributes")]
#[cfg_attr(docsrs, doc(cfg(feature = "attributes")))]
#[doc(inline)]
pub use tracing_attributes::instrument;

Expand Down

0 comments on commit 7e72e1c

Please sign in to comment.