Skip to content

Commit

Permalink
finish doc_cfg for tracing-tower and tracing-log (#537)
Browse files Browse the repository at this point in the history
Closes #440 

this should be the last of them

* finish doc_cfg for tracing-tower

* finish doc_cfg for tracing-log

* Add cargo metadata to tower and log
  • Loading branch information
yaahc authored and hawkw committed Jan 15, 2020
1 parent 8b9fc8e commit dee99ac
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tracing-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ tracing = "0.1"
[badges]
azure-devops = { project = "tracing/tracing", pipeline = "tokio-rs.tracing", build = "1" }
maintenance = { status = "actively-maintained" }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
6 changes: 6 additions & 0 deletions tracing-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
//! [`Subscriber`]: https://docs.rs/tracing/latest/tracing/trait.Subscriber.html
//! [`tracing::Event`]: https://docs.rs/tracing/latest/tracing/struct.Event.html
#![doc(html_root_url = "https://docs.rs/tracing-log/0.1.1")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(
missing_debug_implementations,
missing_docs,
Expand Down Expand Up @@ -123,16 +124,20 @@ use tracing_core::{
};

#[cfg(feature = "log-tracer")]
#[cfg_attr(docsrs, doc(cfg(feature = "log-tracer")))]
pub mod log_tracer;

#[cfg(feature = "trace-logger")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace-logger")))]
pub mod trace_logger;

#[cfg(feature = "log-tracer")]
#[cfg_attr(docsrs, doc(cfg(feature = "log-tracer")))]
#[doc(inline)]
pub use self::log_tracer::LogTracer;

#[cfg(feature = "trace-logger")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace-logger")))]
#[deprecated(
since = "0.1.1",
note = "use the `tracing` crate's \"log\" feature flag instead"
Expand All @@ -142,6 +147,7 @@ pub use self::log_tracer::LogTracer;
pub use self::trace_logger::TraceLogger;

#[cfg(feature = "env_logger")]
#[cfg_attr(docsrs, doc(cfg(feature = "env_logger")))]
pub mod env_logger;

/// Format a log record as a trace event in the current span.
Expand Down
3 changes: 3 additions & 0 deletions tracing-log/src/log_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl LogTracer {
///
/// [`builder`]: #method.builder
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn init_with_filter(level: log::LevelFilter) -> Result<(), SetLoggerError> {
Self::builder().with_max_level(level).init()
}
Expand Down Expand Up @@ -146,6 +147,7 @@ impl LogTracer {
/// [`init_with_filter`]: #method.init_with_filter
/// [`builder`]: #method.builder
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn init() -> Result<(), SetLoggerError> {
Self::builder().init()
}
Expand Down Expand Up @@ -241,6 +243,7 @@ impl Builder {
///
/// Setting a global logger can only be done once.
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn init(self) -> Result<(), SetLoggerError> {
let ignore_crates = self.ignore_crates.into_boxed_slice();
let logger = Box::new(LogTracer { ignore_crates });
Expand Down
4 changes: 4 additions & 0 deletions tracing-tower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ http = { version = "0.1", optional = true }
[badges]
azure-devops = { project = "tracing/tracing", pipeline = "tokio-rs.tracing", build = "1" }
maintenance = { status = "experimental" }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
4 changes: 4 additions & 0 deletions tracing-tower/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(
missing_debug_implementations,
// missing_docs, // TODO: add documentation!
Expand Down Expand Up @@ -29,6 +30,7 @@ pub mod request_span;
pub mod service_span;

#[cfg(feature = "http")]
#[cfg_attr(docsrs, doc(cfg(feature = "http")))]
pub mod http;

pub type InstrumentedService<S, R> = service_span::Service<request_span::Service<S, R>>;
Expand Down Expand Up @@ -65,6 +67,7 @@ where
}

#[cfg(feature = "tower-util")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))]
pub trait InstrumentMake<T, R>
where
Self: tower_util::MakeService<T, R> + Sized,
Expand All @@ -87,6 +90,7 @@ where
impl<S, R> InstrumentableService<R> for S where S: Service<R> + Sized {}

#[cfg(feature = "tower-util")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))]
impl<M, T, R> InstrumentMake<T, R> for M where M: tower_util::MakeService<T, R> {}

pub trait GetSpan<T>: crate::sealed::Sealed<T> {
Expand Down
8 changes: 8 additions & 0 deletions tracing-tower/src/request_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ where
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
pub use self::layer::*;

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
mod layer {
use super::*;

Expand Down Expand Up @@ -70,9 +72,11 @@ mod layer {
}

#[cfg(feature = "tower-make")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-make")))]
pub use self::make::MakeService;

#[cfg(feature = "tower-make")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-make")))]
pub mod make {
use super::*;
use pin_project::pin_project;
Expand All @@ -85,6 +89,7 @@ pub mod make {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
#[derive(Debug)]
pub struct MakeLayer<R, T, G = fn(&R) -> tracing::Span>
where
Expand All @@ -104,6 +109,7 @@ pub mod make {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
pub fn layer<R, T, G>(get_span: G) -> MakeLayer<R, T, G>
where
G: GetSpan<R> + Clone,
Expand All @@ -117,6 +123,7 @@ pub mod make {
// === impl MakeLayer ===

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
impl<S, R, G, T> tower_layer::Layer<S> for MakeLayer<R, T, G>
where
S: tower_make::MakeService<T, R>,
Expand All @@ -130,6 +137,7 @@ pub mod make {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
impl<R, T, G> Clone for MakeLayer<R, T, G>
where
G: GetSpan<R> + Clone,
Expand Down
7 changes: 7 additions & 0 deletions tracing-tower/src/service_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ pub struct Service<S> {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
pub use self::layer::*;

#[cfg(feature = "tower-util")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))]
pub use self::make::MakeService;

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
mod layer {
use super::*;

Expand Down Expand Up @@ -73,6 +76,7 @@ mod layer {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
pub mod make {
use super::*;
use pin_project::pin_project;
Expand Down Expand Up @@ -105,6 +109,7 @@ pub mod make {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
pub fn layer<T, R, G>(get_span: G) -> MakeLayer<T, R, G>
where
G: GetSpan<T> + Clone,
Expand All @@ -118,6 +123,7 @@ pub mod make {
// === impl MakeLayer ===

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
impl<M, T, R, G> tower_layer::Layer<M> for MakeLayer<T, R, G>
where
M: tower_make::MakeService<T, R>,
Expand All @@ -131,6 +137,7 @@ pub mod make {
}

#[cfg(feature = "tower-layer")]
#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))]
impl<T, R, G> Clone for MakeLayer<T, R, G>
where
G: GetSpan<T> + Clone,
Expand Down

0 comments on commit dee99ac

Please sign in to comment.