Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriber: remove deprecated APIs #1673

Merged
merged 4 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions tracing-subscriber/src/fmt/fmt_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,7 @@ pub struct Layer<
_inner: PhantomData<S>,
}

/// A builder for [`Layer`](struct.Layer.html) that logs formatted representations of `tracing`
/// events and spans.
///
/// **Note**: As of `tracing-subscriber` 0.2.4, the separate builder type is now
/// deprecated, as the `Layer` type itself supports all the builder's
/// configuration methods. This is now an alias for `Layer`.
#[deprecated(
since = "0.2.4",
note = "a separate layer builder type is not necessary, `Layer`s now support configuration"
)]
pub type LayerBuilder<
S,
N = format::DefaultFields,
E = format::Format<format::Full>,
W = fn() -> io::Stdout,
> = Layer<S, N, E, W>;

impl<S> Layer<S> {
/// Returns a new [`LayerBuilder`](type.LayerBuilder.html) for configuring a `Layer`.
#[deprecated(
since = "0.2.4",
note = "a separate layer builder is not necessary, use `Layer::new`/`Layer::default` instead"
)]
#[allow(deprecated)]
pub fn builder() -> LayerBuilder<S> {
Layer::default()
}

/// Returns a new [`Layer`](struct.Layer.html) with the default configuration.
pub fn new() -> Self {
Self::default()
Expand Down Expand Up @@ -475,26 +448,6 @@ impl<S, N, E, W> Layer<S, N, E, W> {
}
}

#[allow(deprecated)]
impl<S, N, E, W> LayerBuilder<S, N, E, W>
where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'writer> FormatFields<'writer> + 'static,
E: FormatEvent<S, N> + 'static,
W: for<'writer> MakeWriter<'writer> + 'static,
{
/// Builds a [`Layer`] with the provided configuration.
///
/// [`Layer`]: struct.Layer.html
#[deprecated(
since = "0.2.4",
note = "`LayerBuilder` is no longer a separate type; this method is not necessary"
)]
pub fn finish(self) -> Layer<S, N, E, W> {
self
}
}

impl<S> Default for Layer<S> {
fn default() -> Self {
Layer {
Expand Down
23 changes: 1 addition & 22 deletions tracing-subscriber/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ pub mod format;
pub mod time;
#[cfg_attr(docsrs, doc(cfg(all(feature = "fmt", feature = "std"))))]
pub mod writer;
#[allow(deprecated)]
pub use fmt_layer::LayerBuilder;

pub use fmt_layer::{FmtContext, FormattedFields, Layer};

use crate::layer::Layer as _;
Expand Down Expand Up @@ -1002,26 +1001,6 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
}
}

/// Sets whether or not spans inherit their parents' field values (disabled
/// by default).
#[deprecated(since = "0.2.0", note = "this no longer does anything")]
pub fn inherit_fields(self, inherit_fields: bool) -> Self {
let _ = inherit_fields;
self
}

/// Sets the function that the subscriber being built should use to format
/// events that occur.
#[deprecated(since = "0.2.0", note = "renamed to `event_format`.")]
pub fn on_event<E2>(self, fmt_event: E2) -> SubscriberBuilder<N, E2, F, W>
where
E2: FormatEvent<Registry, N> + 'static,
N: for<'writer> FormatFields<'writer> + 'static,
W: for<'writer> MakeWriter<'writer> + 'static,
{
self.event_format(fmt_event)
}

/// Sets the [`MakeWriter`] that the subscriber being built will use to write events.
///
/// # Examples
Expand Down
37 changes: 0 additions & 37 deletions tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,45 +365,8 @@ where
self.data.metadata().fields()
}

/// Returns the ID of this span's parent, or `None` if this span is the root
/// of its trace tree.
#[deprecated(
note = "this method cannot properly support per-layer filtering, and may \
return the `Id` of a disabled span if per-layer filtering is in \
use. use `.parent().map(SpanRef::id)` instead.",
since = "0.2.21"
)]
pub fn parent_id(&self) -> Option<&Id> {
// XXX(eliza): this doesn't work with PLF because the ID is potentially
// borrowed from a parent we got from the registry, rather than from
// `self`, so we can't return a borrowed parent. so, right now, we just
// return the actual parent ID, and ignore PLF. which is not great.
//
// i think if we want this to play nice with PLF, we should just change
// it to return the `Id` by value instead of `&Id` (which we ought to do
// anyway since an `Id` is just a word) but that's a breaking change.
// alternatively, we could deprecate this method since it can't support
// PLF in its current form (which is what we would want to do if we want
// to release PLF in a minor version)...

// let mut id = self.data.parent()?;
// loop {
// // Is this parent enabled by our filter?
// if self
// .filter
// .map(|filter| self.registry.is_enabled_for(id, filter))
// .unwrap_or(true)
// {
// return Some(id);
// }
// id = self.registry.span_data(id)?.parent()?;
// }
self.data.parent()
}

/// Returns a `SpanRef` describing this span's parent, or `None` if this
/// span is the root of its trace tree.

pub fn parent(&self) -> Option<Self> {
let id = self.data.parent()?;
let data = self.registry.span_data(id)?;
Expand Down