Skip to content

Commit fe59f77

Browse files
authored
chore: rename layers to subscribers and fix some typos (#1272)
1 parent ba7a7f7 commit fe59f77

File tree

16 files changed

+64
-71
lines changed

16 files changed

+64
-71
lines changed

examples/examples/thread-info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![deny(rust_2018_idioms)]
22
/// This is a example showing how thread info can be displayed when
33
/// formatting events with `tracing_subscriber::fmt`. This is useful
4-
/// as `tracing` spans can be entered by multicple threads concurrently,
4+
/// as `tracing` spans can be entered by multiple threads concurrently,
55
/// or move across threads freely.
66
///
77
/// You can run this example by running the following command in a terminal

tracing-appender/src/non_blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub struct WorkerGuard {
118118
///
119119
/// This struct implements [`MakeWriter`][make_writer] from the `tracing-subscriber`
120120
/// crate. Therefore, it can be used with the [`tracing_subscriber::fmt`][fmt] module
121-
/// or with any other subscriber/layer implementation that uses the `MakeWriter` trait.
121+
/// or with any other collector/subscriber implementation that uses the `MakeWriter` trait.
122122
///
123123
/// [make_writer]: tracing_subscriber::fmt::MakeWriter
124124
/// [fmt]: mod@tracing_subscriber::fmt

tracing-core/src/collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub trait Collect: 'static {
9696
/// never be enabled unless a new collector expresses interest in it.
9797
///
9898
/// `Collector`s which require their filters to be run every time an event
99-
/// occurs or a span is entered::exited should return `Interest::sometimes`.
99+
/// occurs or a span is entered/exited should return `Interest::sometimes`.
100100
/// If a collector returns `Interest::sometimes`, then its' [`enabled`] method
101101
/// will be called every time an event or span is created from that callsite.
102102
///
@@ -135,7 +135,7 @@ pub trait Collect: 'static {
135135
/// [filter]: Self::enabled
136136
/// [metadata]: super::metadata::Metadata
137137
/// [`enabled`]: Self::enabled
138-
/// [`rebuild_interest_cache`]: super::callsite::fn.rebuild_interest_cache.html
138+
/// [`rebuild_interest_cache`]: super::callsite::rebuild_interest_cache
139139
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
140140
if self.enabled(metadata) {
141141
Interest::always()
@@ -186,7 +186,7 @@ pub trait Collect: 'static {
186186
/// level changes.
187187
///
188188
/// [level]: super::Level
189-
/// [rebuild]: super::callsite::fn.rebuild_interest_cache.html
189+
/// [rebuild]: super::callsite::rebuild_interest_cache
190190
fn max_level_hint(&self) -> Option<LevelFilter> {
191191
None
192192
}

tracing-error/src/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::layer::WithContext;
1+
use crate::subscriber::WithContext;
22
use std::fmt;
33
use tracing::{Metadata, Span};
44

tracing-error/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! * [`SpanTrace`], a captured trace of the current `tracing` [span] context
1616
//!
17-
//! * [`ErrorSubscriber`], a [subscriber layer] which enables capturing `SpanTrace`s
17+
//! * [`ErrorSubscriber`], a [subscriber] which enables capturing `SpanTrace`s
1818
//!
1919
//! **Note**: This crate is currently experimental.
2020
//!
@@ -161,7 +161,7 @@
161161
//! [span]: mod@tracing::span
162162
//! [events]: tracing::Event
163163
//! [collector]: tracing::Collect
164-
//! [subscriber layer]: tracing_subscriber::subscribe::Subscribe
164+
//! [subscriber]: tracing_subscriber::subscribe::Subscribe
165165
//!
166166
//! ## Supported Rust Versions
167167
//!
@@ -209,12 +209,12 @@
209209
mod backtrace;
210210
#[cfg(feature = "traced-error")]
211211
mod error;
212-
mod layer;
212+
mod subscriber;
213213

214214
pub use self::backtrace::{SpanTrace, SpanTraceStatus};
215215
#[cfg(feature = "traced-error")]
216216
pub use self::error::{ExtractSpanTrace, InstrumentError, InstrumentResult, TracedError};
217-
pub use self::layer::ErrorSubscriber;
217+
pub use self::subscriber::ErrorSubscriber;
218218

219219
#[cfg(feature = "traced-error")]
220220
#[cfg_attr(docsrs, doc(cfg(feature = "traced-error")))]

tracing-error/src/layer.rs renamed to tracing-error/src/subscriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
S: Collect + for<'span> LookupSpan<'span>,
4242
F: for<'writer> FormatFields<'writer> + 'static,
4343
{
44-
/// Notifies this layer that a new span was constructed with the given
44+
/// Notifies this subscriber that a new span was constructed with the given
4545
/// `Attributes` and `Id`.
4646
fn new_span(
4747
&self,

tracing-flame/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ thread_local! {
180180
/// samples.
181181
///
182182
/// The output of `FlameSubscriber` emulates the output of commands like `perf` once
183-
/// they've been collapsed by `inferno-flamegraph`. The output of this layer
183+
/// they've been collapsed by `inferno-flamegraph`. The output of this subscriber
184184
/// should look similar to the output of the following commands:
185185
///
186186
/// ```sh
@@ -266,7 +266,7 @@ where
266266
/// provided writer.
267267
pub fn new(writer: W) -> Self {
268268
// Initialize the start used by all threads when initializing the
269-
// LAST_EVENT when constructing the layer
269+
// LAST_EVENT when constructing the subscriber
270270
let _unused = *START;
271271
Self {
272272
out: Arc::new(Mutex::new(writer)),
@@ -378,9 +378,9 @@ where
378378
})
379379
.map_err(Error)?;
380380
let writer = BufWriter::new(file);
381-
let layer = Self::new(writer);
382-
let guard = layer.flush_on_drop();
383-
Ok((layer, guard))
381+
let subscriber = Self::new(writer);
382+
let guard = subscriber.flush_on_drop();
383+
Ok((subscriber, guard))
384384
}
385385
}
386386

tracing-log/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
//!
6666
//! If the logging of trace events generated from log records produced by the
6767
//! `log` crate is desired, either the `log` crate should not be used to
68-
//! implement this logging, or an additional layer of filtering will be
68+
//! implement this logging, or an additional subscriber of filtering will be
6969
//! required to avoid infinitely converting between `Event` and `log::Record`.
7070
//!
7171
//! # Feature Flags

tracing-subscriber/src/fmt/fmt_subscriber.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ use tracing_core::{
5252
/// use tracing_subscriber::prelude::*;
5353
///
5454
/// let fmt = format().with_timer(time::Uptime::default());
55-
/// let fmt_layer = fmt::subscriber()
55+
/// let fmt_subscriber = fmt::subscriber()
5656
/// .event_format(fmt)
5757
/// .with_target(false);
58-
/// # let subscriber = fmt_layer.with_collector(tracing_subscriber::registry::Registry::default());
58+
/// # let subscriber = fmt_subscriber.with_collector(tracing_subscriber::registry::Registry::default());
5959
/// # tracing::collect::set_global_default(subscriber).unwrap();
6060
/// ```
6161
///
@@ -76,14 +76,14 @@ impl<S> Subscriber<S> {
7676
}
7777
}
7878

79-
// This needs to be a seperate impl block because they place different bounds on the type parameters.
79+
// This needs to be a separate impl block because they place different bounds on the type parameters.
8080
impl<S, N, E, W> Subscriber<S, N, E, W>
8181
where
8282
S: Collect + for<'a> LookupSpan<'a>,
8383
N: for<'writer> FormatFields<'writer> + 'static,
8484
W: for<'writer> MakeWriter<'writer> + 'static,
8585
{
86-
/// Sets the [event formatter][`FormatEvent`] that the layer will use to
86+
/// Sets the [event formatter][`FormatEvent`] that the subscriber will use to
8787
/// format events.
8888
///
8989
/// The event formatter may be any type implementing the [`FormatEvent`]
@@ -96,11 +96,11 @@ where
9696
/// ```rust
9797
/// use tracing_subscriber::fmt::{self, format};
9898
///
99-
/// let layer = fmt::subscriber()
99+
/// let fmt_subscriber = fmt::subscriber()
100100
/// .event_format(format().compact());
101101
/// # // this is necessary for type inference.
102102
/// # use tracing_subscriber::Subscribe as _;
103-
/// # let _ = layer.with_collector(tracing_subscriber::registry::Registry::default());
103+
/// # let _ = fmt_subscriber.with_collector(tracing_subscriber::registry::Registry::default());
104104
/// ```
105105
/// [`FormatEvent`]: format::FormatEvent
106106
/// [`Event`]: tracing::Event
@@ -118,7 +118,7 @@ where
118118
}
119119
}
120120

121-
// This needs to be a seperate impl block because they place different bounds on the type parameters.
121+
// This needs to be a separate impl block because they place different bounds on the type parameters.
122122
impl<S, N, E, W> Subscriber<S, N, E, W> {
123123
/// Sets the [`MakeWriter`] that the [`Subscriber`] being built will use to write events.
124124
///
@@ -130,11 +130,11 @@ impl<S, N, E, W> Subscriber<S, N, E, W> {
130130
/// use std::io;
131131
/// use tracing_subscriber::fmt;
132132
///
133-
/// let layer = fmt::subscriber()
133+
/// let fmt_subscriber = fmt::subscriber()
134134
/// .with_writer(io::stderr);
135135
/// # // this is necessary for type inference.
136136
/// # use tracing_subscriber::Subscribe as _;
137-
/// # let _ = layer.with_collector(tracing_subscriber::registry::Registry::default());
137+
/// # let _ = fmt_subscriber.with_collector(tracing_subscriber::registry::Registry::default());
138138
/// ```
139139
///
140140
/// [`MakeWriter`]: super::writer::MakeWriter
@@ -165,11 +165,11 @@ impl<S, N, E, W> Subscriber<S, N, E, W> {
165165
/// use std::io;
166166
/// use tracing_subscriber::fmt;
167167
///
168-
/// let layer = fmt::subscriber()
168+
/// let fmt_subscriber = fmt::subscriber()
169169
/// .with_test_writer();
170170
/// # // this is necessary for type inference.
171171
/// # use tracing_subscriber::Subscribe as _;
172-
/// # let _ = layer.with_collector(tracing_subscriber::registry::Registry::default());
172+
/// # let _ = fmt_subscriber.with_collector(tracing_subscriber::registry::Registry::default());
173173
/// ```
174174
/// [capturing]:
175175
/// https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output
@@ -384,7 +384,7 @@ where
384384
#[cfg(feature = "json")]
385385
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
386386
impl<S, T, W> Subscriber<S, format::JsonFields, format::Format<format::Json, T>, W> {
387-
/// Sets the JSON layer being built to flatten event metadata.
387+
/// Sets the JSON subscriber being built to flatten event metadata.
388388
///
389389
/// See [`format::Json`]
390390
pub fn flatten_event(
@@ -436,7 +436,7 @@ impl<S, T, W> Subscriber<S, format::JsonFields, format::Format<format::Json, T>,
436436
}
437437

438438
impl<S, N, E, W> Subscriber<S, N, E, W> {
439-
/// Sets the field formatter that the layer being built will use to record
439+
/// Sets the field formatter that the subscriber being built will use to record
440440
/// fields.
441441
pub fn fmt_fields<N2>(self, fmt_fields: N2) -> Subscriber<S, N2, E, W>
442442
where
@@ -527,7 +527,7 @@ impl<E> Deref for FormattedFields<E> {
527527
}
528528
}
529529

530-
// === impl FmtLayer ===
530+
// === impl FmtSubscriber ===
531531

532532
macro_rules! with_event_from_span {
533533
($id:ident, $span:ident, $($field:literal = $value:expr),*, |$event:ident| $code:block) => {
@@ -710,9 +710,9 @@ where
710710
}
711711

712712
unsafe fn downcast_raw(&self, id: TypeId) -> Option<NonNull<()>> {
713-
// This `downcast_raw` impl allows downcasting a `fmt` layer to any of
713+
// This `downcast_raw` impl allows downcasting a `fmt` subscriber to any of
714714
// its components (event formatter, field formatter, and `MakeWriter`)
715-
// as well as to the layer's type itself. The potential use-cases for
715+
// as well as to the subscriber's type itself. The potential use-cases for
716716
// this *may* be somewhat niche, though...
717717
match () {
718718
_ if id == TypeId::of::<Self>() => Some(NonNull::from(self).cast()),
@@ -894,7 +894,7 @@ mod test {
894894
}
895895

896896
#[test]
897-
fn fmt_layer_downcasts() {
897+
fn fmt_subscriber_downcasts() {
898898
let f = format::Format::default();
899899
let fmt = fmt::Subscriber::default().event_format(f);
900900
let subscriber = fmt.with_collector(Registry::default());
@@ -906,7 +906,7 @@ mod test {
906906
}
907907

908908
#[test]
909-
fn fmt_layer_downcasts_to_parts() {
909+
fn fmt_subscriber_downcasts_to_parts() {
910910
let f = format::Format::default();
911911
let fmt = fmt::Subscriber::default().event_format(f);
912912
let subscriber = fmt.with_collector(Registry::default());

tracing-subscriber/src/fmt/format/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ use fmt::{Debug, Display};
3939

4040
/// A type that can format a tracing `Event` for a `fmt::Write`.
4141
///
42-
/// `FormatEvent` is primarily used in the context of [`fmt::Collector`] or [`fmt::Subscriber`]. Each time an event is
43-
/// dispatched to [`fmt::Collector`] or [`fmt::Subscriber`], the subscriber or layer forwards it to
44-
/// its associated `FormatEvent` to emit a log message.
42+
/// `FormatEvent` is primarily used in the context of [`fmt::Collector`] or [`fmt::Subscriber`].
43+
/// Each time an event is dispatched to [`fmt::Collector`] or [`fmt::Subscriber`],
44+
/// the collector or subscriber forwards it to its associated `FormatEvent` to emit a log message.
4545
///
4646
/// This trait is already implemented for function pointers with the same
4747
/// signature as `format_event`.
@@ -191,11 +191,14 @@ pub trait FormatFields<'writer> {
191191
/// .event_format(format)
192192
/// .init();
193193
/// ```
194+
/// [event formatter]: FormatEvent
194195
pub fn format() -> Format {
195196
Format::default()
196197
}
197198

198199
/// Returns the default configuration for a JSON [event formatter].
200+
///
201+
/// [event formatter]: FormatEvent
199202
#[cfg(feature = "json")]
200203
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
201204
pub fn json() -> Format<Json> {

0 commit comments

Comments
 (0)