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", "tempfile",
"tokio", "tokio",
"tokio-util", "tokio-util",
"tower-http",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"zip", "zip",
@ -1133,6 +1134,7 @@ dependencies = [
"tower", "tower",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing",
] ]
[[package]] [[package]]

View file

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

View file

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