Add logging

This commit is contained in:
2023-07-23 21:45:57 +02:00
parent b3d18f0234
commit 6d6b098b1d
4 changed files with 69 additions and 1 deletions

View File

@@ -21,6 +21,11 @@ async fn start_app() {
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_target(false)
.compact()
.init();
let _guard = sentry::init(config::CONFIG.sentry_dsn.clone());
env_logger::init();

View File

@@ -1,4 +1,6 @@
use axum::{Router, response::Response, http::{StatusCode, self, Request}, middleware::{Next, self}};
use tower_http::trace::{TraceLayer, self};
use tracing::Level;
use crate::config::CONFIG;
@@ -33,4 +35,11 @@ pub fn get_router() -> Router {
.nest("/languages/", languages::get_router())
.nest("/donate_notifications/", donate_notifications::get_router())
.layer(middleware::from_fn(auth))
.layer(
TraceLayer::new_for_http()
.make_span_with(trace::DefaultMakeSpan::new()
.level(Level::INFO))
.on_response(trace::DefaultOnResponse::new()
.level(Level::INFO)),
)
}