chore: add TraceLayer for per-request method and path logging

This commit is contained in:
2026-04-27 21:59:07 +03:00
parent a120838cbc
commit e6b5cb75ba
3 changed files with 8 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ mod web;
use anyhow::Result;
use axum::{Router, middleware, response::Response};
use tower_cookies::CookieManagerLayer;
use tower_http::services::ServeDir;
use tower_http::{services::ServeDir, trace::TraceLayer};
use tracing::info;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
@@ -25,7 +25,7 @@ async fn main() -> Result<()> {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
format!("{}=info,tower_http=info", env!("CARGO_CRATE_NAME")).into()
format!("{}=info,tower_http=debug", env!("CARGO_CRATE_NAME")).into()
}),
)
.with(tracing_subscriber::fmt::layer())
@@ -40,6 +40,7 @@ async fn main() -> Result<()> {
.nest("/api", routes_file)
.merge(routes_health())
.merge(routes_login())
.layer(TraceLayer::new_for_http())
.layer(middleware::map_response(main_response_mapper))
.layer(middleware::from_fn_with_state(
file_controller,