Skip to content

Commit

Permalink
Use the module_path! macro in the example to simplify the tracing s…
Browse files Browse the repository at this point in the history
…etup code
  • Loading branch information
hongweipeng committed Aug 21, 2024
1 parent bd3eaa7 commit 0111e70
Show file tree
Hide file tree
Showing 27 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion examples/chat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_chat=trace".into()),
.unwrap_or_else(|_| format!("{}=trace", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/compression/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example-compression=trace".into()),
.unwrap_or_else(|_| format!("{}=trace", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_consume_body_in_extractor_or_middleware=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/customize-extractor-error/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_customize_extractor_error=trace".into()),
.unwrap_or_else(|_| format!("{}=trace", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/customize-path-rejection/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_customize_path_rejection=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/dependency-injection/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_dependency_injection=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/diesel-async-postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_diesel_async_postgres=debug".into()),
.unwrap_or_else(|_| format!("{}=trace", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/diesel-postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_tokio_postgres=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/error-handling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_error_handling=debug,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=debug,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/form/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_form=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/global-404-handler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_global_404_handler=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/graceful-shutdown/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
"example_graceful_shutdown=debug,tower_http=debug,axum=trace".into()
format!("{}=debug,tower_http=debug,axum=trace", module_path!()).into()
}),
)
.with(tracing_subscriber::fmt::layer().without_time())
Expand Down
2 changes: 1 addition & 1 deletion examples/http-proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_http_proxy=trace,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=trace,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/jwt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_jwt=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/key-value-store/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_key_value_store=debug,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=debug,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/low-level-openssl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_low_level_openssl=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/low-level-rustls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_low_level_rustls=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/multipart-form/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_multipart_form=debug,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=debug,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/tls-graceful-shutdown/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_tls_graceful_shutdown=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/tls-rustls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_tls_rustls=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/todos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_todos=debug,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=debug,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/tokio-postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_tokio_postgres=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/tokio-redis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_tokio_redis=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing-aka-logging/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() {
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
// axum logs rejections from built-in extractors with the `axum::rejection`
// target, at `TRACE` level. `axum::rejection=trace` enables showing those events
"example_tracing_aka_logging=debug,tower_http=debug,axum::rejection=trace".into()
format!("{}=debug,tower_http=debug,axum::rejection=trace", module_path!()).into()
}),
)
.with(tracing_subscriber::fmt::layer())
Expand Down
2 changes: 1 addition & 1 deletion examples/validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_validator=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/versioning/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_versioning=debug".into()),
.unwrap_or_else(|_| format!("{}=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down
2 changes: 1 addition & 1 deletion examples/websockets/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "example_websockets=debug,tower_http=debug".into()),
.unwrap_or_else(|_| format!("{}=debug,tower_http=debug", module_path!()).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
Expand Down

0 comments on commit 0111e70

Please sign in to comment.