feat: Add request logging, supress noisy stuff from hyper

This commit is contained in:
Ashhhleyyy 2022-07-05 11:45:17 +01:00
parent d1d12bdfb5
commit fdba86ca60
Signed by: ash
GPG key ID: 83B789081A0878FB
3 changed files with 8 additions and 2 deletions

2
Cargo.lock generated
View file

@ -815,6 +815,7 @@ dependencies = [
"tempfile",
"tokio",
"tokio-util",
"tower-http",
"tracing",
"tracing-subscriber",
"zip",
@ -1133,6 +1134,7 @@ dependencies = [
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]

View file

@ -13,6 +13,7 @@ mime_guess = "2.0.4"
tempfile = "3.3.0"
tokio = { version = "1.19.2", features = ["full"] }
tokio-util = { version = "0.7.3", features = ["io"] }
tower-http = { version = "0.3.4", features = ["trace"] }
tracing = "0.1.35"
tracing-subscriber = { version = "0.3.14", features = ["env-filter"] }
zip = "0.6.2"

View file

@ -3,6 +3,7 @@ use std::{fs, path::Path};
use axum::Extension;
use color_eyre::{eyre::eyre, Result};
use projects::AuthToken;
use tower_http::trace::TraceLayer;
use tracing_subscriber::prelude::*;
mod projects;
@ -14,7 +15,7 @@ async fn main() -> Result<()> {
tracing_subscriber::registry()
.with(tracing_subscriber::filter::EnvFilter::new(
std::env::var("RUST_LOG").unwrap_or_else(|_| "debug".into()),
std::env::var("RUST_LOG").unwrap_or_else(|_| "debug,hyper=info".into()),
))
.with(tracing_subscriber::fmt::layer())
.init();
@ -32,7 +33,9 @@ async fn main() -> Result<()> {
fs::create_dir_all(archive_dir)?;
}
let app = routes::router().layer(Extension(AuthToken(upload_token)));
let app = routes::router()
.layer(Extension(AuthToken(upload_token)))
.layer(TraceLayer::new_for_http());
let port: u16 = std::env::var("PORT")
.map(|s| s.parse().unwrap())