diff --git a/examples/chat/src/main.rs b/examples/chat/src/main.rs index 32b3861395..9f3452852b 100644 --- a/examples/chat/src/main.rs +++ b/examples/chat/src/main.rs @@ -33,9 +33,10 @@ struct AppState { #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_chat=trace".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_chat=trace".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/consume-body-in-extractor-or-middleware/src/main.rs b/examples/consume-body-in-extractor-or-middleware/src/main.rs index b3363d9976..f8ae4e491a 100644 --- a/examples/consume-body-in-extractor-or-middleware/src/main.rs +++ b/examples/consume-body-in-extractor-or-middleware/src/main.rs @@ -22,10 +22,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_consume_body_in_extractor_or_middleware=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/customize-extractor-error/src/main.rs b/examples/customize-extractor-error/src/main.rs index b7b24f7623..c5359db56d 100644 --- a/examples/customize-extractor-error/src/main.rs +++ b/examples/customize-extractor-error/src/main.rs @@ -15,10 +15,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_customize_extractor_error=trace".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/customize-path-rejection/src/main.rs b/examples/customize-path-rejection/src/main.rs index 68baf8f879..a1cd38661d 100644 --- a/examples/customize-path-rejection/src/main.rs +++ b/examples/customize-path-rejection/src/main.rs @@ -19,10 +19,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_customize_path_rejection=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/error-handling-and-dependency-injection/src/main.rs b/examples/error-handling-and-dependency-injection/src/main.rs index af897e3aa6..b0964caa99 100644 --- a/examples/error-handling-and-dependency-injection/src/main.rs +++ b/examples/error-handling-and-dependency-injection/src/main.rs @@ -24,10 +24,10 @@ use uuid::Uuid; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_error_handling_and_dependency_injection=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/form/src/main.rs b/examples/form/src/main.rs index 7605bafffb..233d0cb3bf 100644 --- a/examples/form/src/main.rs +++ b/examples/form/src/main.rs @@ -12,9 +12,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_form=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_form=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/global-404-handler/src/main.rs b/examples/global-404-handler/src/main.rs index a3a5ea15dc..eeacb61e11 100644 --- a/examples/global-404-handler/src/main.rs +++ b/examples/global-404-handler/src/main.rs @@ -16,9 +16,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_global_404_handler=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_global_404_handler=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/http-proxy/src/main.rs b/examples/http-proxy/src/main.rs index bfb25199be..27d3b85046 100644 --- a/examples/http-proxy/src/main.rs +++ b/examples/http-proxy/src/main.rs @@ -28,10 +28,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_http_proxy=trace,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/jwt/src/main.rs b/examples/jwt/src/main.rs index 82633d96d1..4ee20d4bf7 100644 --- a/examples/jwt/src/main.rs +++ b/examples/jwt/src/main.rs @@ -56,9 +56,10 @@ static KEYS: Lazy = Lazy::new(|| { #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_jwt=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_jwt=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/key-value-store/src/main.rs b/examples/key-value-store/src/main.rs index 5d6c2bf7e7..1521c5ffc9 100644 --- a/examples/key-value-store/src/main.rs +++ b/examples/key-value-store/src/main.rs @@ -33,10 +33,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_key_value_store=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/low-level-rustls/src/main.rs b/examples/low-level-rustls/src/main.rs index 331b8c9048..16de3ac1ed 100644 --- a/examples/low-level-rustls/src/main.rs +++ b/examples/low-level-rustls/src/main.rs @@ -30,9 +30,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_tls_rustls=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_tls_rustls=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/multipart-form/src/main.rs b/examples/multipart-form/src/main.rs index bcddc60a6d..ee881d2839 100644 --- a/examples/multipart-form/src/main.rs +++ b/examples/multipart-form/src/main.rs @@ -17,10 +17,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_multipart_form=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/oauth/src/main.rs b/examples/oauth/src/main.rs index ea692df84d..1a01570f69 100644 --- a/examples/oauth/src/main.rs +++ b/examples/oauth/src/main.rs @@ -33,9 +33,10 @@ static COOKIE_NAME: &str = "SESSION"; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_oauth=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_oauth=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/parse-body-based-on-content-type/src/main.rs b/examples/parse-body-based-on-content-type/src/main.rs index 9167d1e05c..49c6d00571 100644 --- a/examples/parse-body-based-on-content-type/src/main.rs +++ b/examples/parse-body-based-on-content-type/src/main.rs @@ -21,11 +21,11 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| { + .with( + tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| { "example_parse_body_based_on_content_type=debug,tower_http=debug".into() }), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/print-request-response/src/main.rs b/examples/print-request-response/src/main.rs index 59c609dd83..7fa568f8b0 100644 --- a/examples/print-request-response/src/main.rs +++ b/examples/print-request-response/src/main.rs @@ -18,10 +18,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_print_request_response=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/prometheus-metrics/src/main.rs b/examples/prometheus-metrics/src/main.rs index 5ab3fbddde..e02bf7352a 100644 --- a/examples/prometheus-metrics/src/main.rs +++ b/examples/prometheus-metrics/src/main.rs @@ -66,10 +66,10 @@ async fn start_metrics_server() { #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_todos=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/rest-grpc-multiplex/src/main.rs b/examples/rest-grpc-multiplex/src/main.rs index ab38e89e12..2ffc277592 100644 --- a/examples/rest-grpc-multiplex/src/main.rs +++ b/examples/rest-grpc-multiplex/src/main.rs @@ -48,10 +48,10 @@ async fn web_root() -> &'static str { async fn main() { // initialize tracing tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_rest_grpc_multiplex=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/sessions/src/main.rs b/examples/sessions/src/main.rs index 716ee41af1..a325b2884c 100644 --- a/examples/sessions/src/main.rs +++ b/examples/sessions/src/main.rs @@ -30,9 +30,10 @@ const AXUM_SESSION_COOKIE_NAME: &str = "axum_session"; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_sessions=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_sessions=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/sqlx-postgres/src/main.rs b/examples/sqlx-postgres/src/main.rs index 0330edabd2..c23b9224f8 100644 --- a/examples/sqlx-postgres/src/main.rs +++ b/examples/sqlx-postgres/src/main.rs @@ -28,9 +28,10 @@ use std::{net::SocketAddr, time::Duration}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_tokio_postgres=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_tokio_postgres=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/sse/src/main.rs b/examples/sse/src/main.rs index 6679971152..305c959c33 100644 --- a/examples/sse/src/main.rs +++ b/examples/sse/src/main.rs @@ -20,10 +20,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_sse=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/static-file-server/src/main.rs b/examples/static-file-server/src/main.rs index 90cfc5e4f8..1ff4cf90ad 100644 --- a/examples/static-file-server/src/main.rs +++ b/examples/static-file-server/src/main.rs @@ -24,10 +24,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_static_file_server=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/stream-to-file/src/main.rs b/examples/stream-to-file/src/main.rs index 018d3d2fdc..38e88eff05 100644 --- a/examples/stream-to-file/src/main.rs +++ b/examples/stream-to-file/src/main.rs @@ -23,9 +23,10 @@ const UPLOADS_DIRECTORY: &str = "uploads"; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_stream_to_file=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_stream_to_file=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/templates/src/main.rs b/examples/templates/src/main.rs index 90ea206b75..c23215bef6 100644 --- a/examples/templates/src/main.rs +++ b/examples/templates/src/main.rs @@ -18,9 +18,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_templates=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_templates=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/testing/src/main.rs b/examples/testing/src/main.rs index 0bb9b352a0..b2041bef9e 100644 --- a/examples/testing/src/main.rs +++ b/examples/testing/src/main.rs @@ -14,10 +14,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_testing=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/tls-rustls/src/main.rs b/examples/tls-rustls/src/main.rs index 6eec0e9c2a..e73f425ff6 100644 --- a/examples/tls-rustls/src/main.rs +++ b/examples/tls-rustls/src/main.rs @@ -25,9 +25,10 @@ struct Ports { #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_tls_rustls=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_tls_rustls=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 98910c5a05..7576d18695 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -36,10 +36,10 @@ use uuid::Uuid; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_todos=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/tokio-postgres/src/main.rs b/examples/tokio-postgres/src/main.rs index faef52b5b9..33c703ca40 100644 --- a/examples/tokio-postgres/src/main.rs +++ b/examples/tokio-postgres/src/main.rs @@ -20,9 +20,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_tokio_postgres=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_tokio_postgres=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/tracing-aka-logging/src/main.rs b/examples/tracing-aka-logging/src/main.rs index 8da6e5fed8..a075f46be7 100644 --- a/examples/tracing-aka-logging/src/main.rs +++ b/examples/tracing-aka-logging/src/main.rs @@ -19,10 +19,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_tracing_aka_logging=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/unix-domain-socket/src/main.rs b/examples/unix-domain-socket/src/main.rs index 2f67a4c1e7..df28bbb08a 100644 --- a/examples/unix-domain-socket/src/main.rs +++ b/examples/unix-domain-socket/src/main.rs @@ -45,9 +45,10 @@ mod unix { pub async fn server() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/validator/src/main.rs b/examples/validator/src/main.rs index 359be614d3..692ee801e0 100644 --- a/examples/validator/src/main.rs +++ b/examples/validator/src/main.rs @@ -27,9 +27,10 @@ use validator::Validate; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_validator=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_validator=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/versioning/src/main.rs b/examples/versioning/src/main.rs index 6948eb1d20..8849b64e45 100644 --- a/examples/versioning/src/main.rs +++ b/examples/versioning/src/main.rs @@ -18,9 +18,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG").unwrap_or_else(|_| "example_versioning=debug".into()), - )) + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_versioning=debug".into()), + ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs index a317bfa470..2ee9f749c5 100644 --- a/examples/websockets/src/main.rs +++ b/examples/websockets/src/main.rs @@ -26,10 +26,10 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::new( - std::env::var("RUST_LOG") + .with( + tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "example_websockets=debug,tower_http=debug".into()), - )) + ) .with(tracing_subscriber::fmt::layer()) .init();