diff --git a/doc/draft.md b/doc/draft.md index cbac6bd..6584f68 100644 --- a/doc/draft.md +++ b/doc/draft.md @@ -7,6 +7,8 @@ This example is meant to show basic service-based IMAP server with boitalettres - [Source code](../examples/simple.rs) ```shell +$ export RUST_LOG="info,simple=trace,boitalettres=trace" +$ export RUSTFLAGS="--cfg tokio_unstable" $ cargo run --example simple ``` diff --git a/examples/simple.rs b/examples/simple.rs index 12e0bc0..8576ddd 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,6 +1,7 @@ use boitalettres::proto::{Request, Response}; use boitalettres::server::accept::addr::{AddrIncoming, AddrStream}; use boitalettres::server::Server; +use tracing_subscriber; async fn handle_req(req: Request) -> eyre::Result { use imap_codec::types::response::Status; @@ -14,7 +15,7 @@ async fn handle_req(req: Request) -> eyre::Result { #[tokio::main] async fn main() -> eyre::Result<()> { - setup_logging(); + tracing_subscriber::fmt::init(); let incoming = AddrIncoming::new("127.0.0.1:4567").await?; @@ -33,23 +34,3 @@ async fn main() -> eyre::Result<()> { Ok(()) } - -// Don't mind this, this is just for debugging. -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(); -}