diff --git a/doc/draft.md b/doc/draft.md index cbac6bd..b232929 100644 --- a/doc/draft.md +++ b/doc/draft.md @@ -10,6 +10,12 @@ This example is meant to show basic service-based IMAP server with boitalettres $ cargo run --example simple ``` +If you want to trace this `simple` example with the [`tokio-console`](https://github.com/tokio-rs/console/tree/main/tokio-console) utility, run: + +```shell +$ RUSTFLAGS="tokio_unstable" cargo run --example simple --features "tokio/tracing" +``` + - [Basic python testing script](../scripts/test_imap.py) ```shell diff --git a/examples/simple.rs b/examples/simple.rs index 37f795f..7e4d440 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -40,18 +40,20 @@ async fn main() -> Result<()> { fn setup_logging() { use tracing_subscriber::prelude::*; - tracing_subscriber::registry() - .with(console_subscriber::spawn()) - .with( - tracing_subscriber::fmt::layer().with_filter( - tracing_subscriber::filter::Targets::new() - .with_default(tracing::Level::DEBUG) - .with_target("boitalettres", tracing::Level::TRACE) - .with_target("simple", tracing::Level::TRACE) - .with_target("tower", tracing::Level::TRACE) - .with_target("tokio_tower", tracing::Level::TRACE) - .with_target("mio", tracing::Level::TRACE), - ), - ) - .init(); + let registry = tracing_subscriber::registry().with( + tracing_subscriber::fmt::layer().with_filter( + tracing_subscriber::filter::Targets::new() + .with_default(tracing::Level::DEBUG) + .with_target("boitalettres", tracing::Level::TRACE) + .with_target("simple", tracing::Level::TRACE) + .with_target("tower", tracing::Level::TRACE) + .with_target("tokio_tower", tracing::Level::TRACE) + .with_target("mio", tracing::Level::TRACE), + ), + ); + + #[cfg(tokio_unstable)] + let registry = registry.with(console_subscriber::spawn()); + + registry.init(); }