Skip to content

Commit

Permalink
Merge branch 'master' into fix-readme-typo
Browse files Browse the repository at this point in the history
  • Loading branch information
hds authored Nov 30, 2024
2 parents 352e8a7 + 93c533b commit 6a38b98
Show file tree
Hide file tree
Showing 111 changed files with 1,478 additions and 673 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ jobs:
- tracing
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install Rust 1.81
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.81
target: wasm32-unknown-unknown
- name: install test runner for wasm
uses: taiki-e/install-action@wasm-pack
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ members = [
"tracing-journald",
"examples"
]

# This will be ignored with Rust older than 1.74, but for now that's okay;
# we're only using it to fix check-cfg issues that first appeared in Rust 1.80.
[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(flaky_tests)", "cfg(tracing_unstable)"] }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[docs-badge]: https://docs.rs/tracing/badge.svg
[docs-url]: https://docs.rs/tracing
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue
[docs-master-url]: https://tracing-rs.netlify.com
[docs-master-url]: https://tracing.rs
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: LICENSE
[actions-badge]: https://github.com/tokio-rs/tracing/workflows/CI/badge.svg
Expand Down
5 changes: 4 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tracing-examples"
version = "0.0.0"
publish = false
edition = "2018"
rust-version = "1.63.0"
rust-version = "1.64.0"

[features]
default = []
Expand Down Expand Up @@ -50,3 +50,6 @@ tempfile = "3.3.0"
# fmt examples
snafu = "0.6.10"
thiserror = "1.0.31"

[lints]
workspace = true
2 changes: 2 additions & 0 deletions examples/examples/all-levels.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
use tracing::Level;

#[no_mangle]
Expand Down
4 changes: 3 additions & 1 deletion examples/examples/appender-multifile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates the use of multiple files with
//! `tracing-appender`'s `RollingFileAppender`
//!
use tracing_appender::rolling;
use tracing_subscriber::fmt::writer::MakeWriterExt;

Expand Down
3 changes: 3 additions & 0 deletions examples/examples/async-fn.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! Demonstrates using the `trace` attribute macro to instrument `async`
//! functions.
//!
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/attrs-args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]

use tracing::{debug, info};
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/attrs-basic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]

use tracing::{debug, info, span, Level};
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/attrs-literal-field-names.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]

use tracing::{debug, span, Level};
Expand Down
4 changes: 3 additions & 1 deletion examples/examples/counters.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]

use tracing::{
Expand Down Expand Up @@ -29,7 +31,7 @@ struct Count<'a> {
counters: RwLockReadGuard<'a, HashMap<String, AtomicUsize>>,
}

impl<'a> Visit for Count<'a> {
impl Visit for Count<'_> {
fn record_i64(&mut self, field: &Field, value: i64) {
if let Some(counter) = self.counters.get(field.name()) {
if value > 0 {
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/custom-error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates using the `tracing-error` crate's `SpanTrace` type
//! to attach a trace context to a custom error type.
#![deny(rust_2018_idioms)]
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/echo.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! A "hello world" echo server [from Tokio][echo-example]
//!
//! This server will create a TCP listener, accept connections in a loop, and
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt-compact.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt-custom-event.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/fmt-custom-field.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates overriding the way `tracing-subscriber`'s
//! `FmtSubscriber` formats fields on spans and events, using a closure.
//!
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt-json.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/fmt-multiple-writers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! An example demonstrating how `fmt::Subcriber` can write to multiple
//! destinations (in this instance, `stdout` and a file) simultaneously.
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt-pretty.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/fmt-source-locations.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! Demonstrates displaying events' source code locations with the `fmt`
//! subscriber.
#![deny(rust_2018_idioms)]
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt-stderr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
use std::io;
use tracing::error;
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/fmt/yak_shave.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
use snafu::{ResultExt, Snafu};
use std::error::Error;
use thiserror::Error;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/futures-proxy-server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! A proxy that forwards data to another server and forwards that server's
//! responses back to clients.
//!
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/hyper-echo.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]

use http::{Method, Request, Response, StatusCode};
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/inferno-flame.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
use std::{
env,
fs::File,
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/instrumented-error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates using the `tracing-error` crate's `SpanTrace` type
//! to attach a trace context to a custom error type.
#![deny(rust_2018_idioms)]
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/journald.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
use tracing::{error, info};
use tracing_subscriber::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/log.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/map-traced-error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! An example on composing errors inside of a `TracedError`, such that the
//! SpanTrace captured is captured when creating the inner error, but still wraps
//! the outer error.
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/panic_hook.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates how `tracing` events can be recorded from within a
//! panic hook, capturing the span context in which the program panicked.
//!
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/serde-yak-shave.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
use std::sync::atomic::{AtomicUsize, Ordering};

use tracing::debug;
Expand Down
3 changes: 3 additions & 0 deletions examples/examples/sloggish/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! A simple example demonstrating how one might implement a custom
//! collector.
//!
Expand Down
6 changes: 4 additions & 2 deletions examples/examples/sloggish/sloggish_collector.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
use nu_ansi_term::{Color, Style};
use tracing::{
field::{Field, Visit},
Expand Down Expand Up @@ -76,7 +78,7 @@ struct Event<'a> {

struct ColorLevel<'a>(&'a Level);

impl<'a> fmt::Display for ColorLevel<'a> {
impl fmt::Display for ColorLevel<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self.0 {
Level::TRACE => Color::Purple.paint("TRACE"),
Expand Down Expand Up @@ -107,7 +109,7 @@ impl Visit for Span {
}
}

impl<'a> Visit for Event<'a> {
impl Visit for Event<'_> {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
write!(
&mut self.stderr,
Expand Down
16 changes: 9 additions & 7 deletions examples/examples/spawny-thing.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//! This is a example showing how information is scoped.
//!
//! You can run this example by running the following command in a terminal
//!
//! ```
//! cargo run --example spawny_thing
//! ```
#![deny(rust_2018_idioms)]

/// This is a example showing how information is scoped.
///
/// You can run this example by running the following command in a terminal
///
/// ```
/// cargo run --example spawny_thing
/// ```
use futures::future::join_all;
use std::error::Error;
use tracing::{debug, info};
Expand Down
2 changes: 2 additions & 0 deletions examples/examples/subscriber-filter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
#![deny(rust_2018_idioms)]
#[path = "fmt/yak_shave.rs"]
mod yak_shave;
Expand Down
39 changes: 21 additions & 18 deletions examples/examples/thread-info.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This is a example showing how thread info can be displayed when
//! formatting events with `tracing_subscriber::fmt`. This is useful
//! as `tracing` spans can be entered by multiple threads concurrently,
//! or move across threads freely.
//!
//! You can run this example by running the following command in a terminal
//!
//! ```
//! cargo run --example thread-info
//! ```
//!
//! Example output:
//!
//! ```not_rust
//! Jul 17 00:38:07.177 INFO ThreadId(02) thread_info: i=9
//! Jul 17 00:38:07.177 INFO thread 1 ThreadId(03) thread_info: i=9
//! Jul 17 00:38:07.177 INFO large name thread 2 ThreadId(04) thread_info: i=9
//! ```
#![deny(rust_2018_idioms)]
/// This is a example showing how thread info can be displayed when
/// formatting events with `tracing_subscriber::fmt`. This is useful
/// as `tracing` spans can be entered by multiple threads concurrently,
/// or move across threads freely.
///
/// You can run this example by running the following command in a terminal
///
/// ```
/// cargo run --example thread-info
/// ```
///
/// Example output:
///
/// ```not_rust
/// Jul 17 00:38:07.177 INFO ThreadId(02) thread_info: i=9
/// Jul 17 00:38:07.177 INFO thread 1 ThreadId(03) thread_info: i=9
/// Jul 17 00:38:07.177 INFO large name thread 2 ThreadId(04) thread_info: i=9
/// ```
use std::thread;
use std::time::Duration;
use tracing::info;
Expand Down
23 changes: 13 additions & 10 deletions examples/examples/toggle-subscribers.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This is a example showing how `Subscriber`s can be enabled or disabled by
//! by wrapping them with an `Option`. This example shows `fmt` and `json`
//! being toggled based on the `json` command line flag.
//!
//! You can run this example by running the following command in a terminal
//!
//! ```
//! cargo run --example toggle-subscribers -- --json
//! ```
//!
#![deny(rust_2018_idioms)]
/// This is a example showing how `Subscriber`s can be enabled or disabled by
/// by wrapping them with an `Option`. This example shows `fmt` and `json`
/// being toggled based on the `json` command line flag.
///
/// You can run this example by running the following command in a terminal
///
/// ```
/// cargo run --example toggle-subscribers -- --json
/// ```
///
use argh::FromArgs;
use tracing::info;
use tracing_subscriber::{subscribe::CollectExt, util::SubscriberInitExt};
Expand Down
19 changes: 11 additions & 8 deletions examples/examples/tokio-spawny-thing.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This is a example showing how information is scoped with tokio's
//! `task::spawn`.
//!
//! You can run this example by running the following command in a terminal
//!
//! ```
//! cargo run --example tokio-spawny-thing
//! ```
#![deny(rust_2018_idioms)]
/// This is a example showing how information is scoped with tokio's
/// `task::spawn`.
///
/// You can run this example by running the following command in a terminal
///
/// ```
/// cargo run --example tokio-spawny-thing
/// ```
use futures::future::try_join_all;
use tracing::{debug, info, instrument, span, Instrument as _, Level};

Expand Down
3 changes: 3 additions & 0 deletions examples/examples/tokio_panic_hook.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! NOTE: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem. For the
//! release examples, please see the `v0.1.x` branch instead.
//!
//! This example demonstrates that a custom panic hook can be used to log panic
//! messages even when panics are captured (such as when a Tokio task panics).
//!
Expand Down
Loading

0 comments on commit 6a38b98

Please sign in to comment.