diff --git a/examples/async-graphql/Cargo.toml b/examples/async-graphql/Cargo.toml index 0463c29a..96c22469 100644 --- a/examples/async-graphql/Cargo.toml +++ b/examples/async-graphql/Cargo.toml @@ -7,7 +7,5 @@ publish = false [dependencies] axum = { path = "../../axum" } tokio = { version = "1.0", features = ["full"] } -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } async-graphql = "3.0" slab = "0.4.3" diff --git a/examples/async-graphql/src/main.rs b/examples/async-graphql/src/main.rs index f26f25b8..9bc47a03 100644 --- a/examples/async-graphql/src/main.rs +++ b/examples/async-graphql/src/main.rs @@ -1,3 +1,11 @@ +//! Example async-graphql application. +//! +//! Run with +//! +//! ```not_rust +//! cargo run -p example-async-graphql +//! ``` + mod starwars; use async_graphql::{ diff --git a/examples/chat/src/main.rs b/examples/chat/src/main.rs index 8adbd52f..52c02a90 100644 --- a/examples/chat/src/main.rs +++ b/examples/chat/src/main.rs @@ -31,6 +31,12 @@ struct AppState { #[tokio::main] async fn main() { + // Set the RUST_LOG, if it hasn't been explicitly defined + if std::env::var_os("RUST_LOG").is_none() { + std::env::set_var("RUST_LOG", "example_chat=trace") + } + tracing_subscriber::fmt::init(); + let user_set = Mutex::new(HashSet::new()); let (tx, _rx) = broadcast::channel(100); @@ -42,7 +48,7 @@ async fn main() { .layer(Extension(app_state)); let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); - + tracing::debug!("listening on {}", addr); axum::Server::bind(&addr) .serve(app.into_make_service()) .await @@ -62,7 +68,6 @@ async fn websocket(stream: WebSocket, state: Arc) { // Username gets set in the receive loop, if it's valid. let mut username = String::new(); - // Loop until a text message is found. while let Some(Ok(message)) = receiver.next().await { if let Message::Text(name) = message { @@ -88,6 +93,7 @@ async fn websocket(stream: WebSocket, state: Arc) { // Send joined message to all subscribers. let msg = format!("{} joined.", username); + tracing::debug!("{}", msg); let _ = state.tx.send(msg); // This task will receive broadcast messages and send text message to our client. @@ -120,8 +126,8 @@ async fn websocket(stream: WebSocket, state: Arc) { // Send user left message. let msg = format!("{} left.", username); + tracing::debug!("{}", msg); let _ = state.tx.send(msg); - // Remove username from map so new clients can take it. state.user_set.lock().unwrap().remove(&username); } diff --git a/examples/print-request-response/Cargo.toml b/examples/print-request-response/Cargo.toml index 83c4b5b5..69781c11 100644 --- a/examples/print-request-response/Cargo.toml +++ b/examples/print-request-response/Cargo.toml @@ -6,7 +6,6 @@ publish = false [dependencies] axum = { path = "../../axum" } -axum-extra = { path = "../../axum-extra" } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version="0.3", features = ["env-filter"] } diff --git a/examples/prometheus-metrics/Cargo.toml b/examples/prometheus-metrics/Cargo.toml index e24b09d8..03d40f8c 100644 --- a/examples/prometheus-metrics/Cargo.toml +++ b/examples/prometheus-metrics/Cargo.toml @@ -6,7 +6,6 @@ publish = false [dependencies] axum = { path = "../../axum" } -axum-extra = { path = "../../axum-extra" } metrics = "0.18" metrics-exporter-prometheus = "0.8" tokio = { version = "1.0", features = ["full"] } diff --git a/examples/reverse-proxy/Cargo.toml b/examples/reverse-proxy/Cargo.toml index e13c0d88..bc77aa5a 100644 --- a/examples/reverse-proxy/Cargo.toml +++ b/examples/reverse-proxy/Cargo.toml @@ -7,5 +7,3 @@ edition = "2018" axum = { path = "../../axum" } hyper = { version = "0.14", features = ["full"] } tokio = { version = "1", features = ["full"] } -tracing = "0.1" -tracing-subscriber = { version="0.3", features = ["env-filter"] }