From 27ff3d00bd770e2ebe2e42acc28356ac5b8efaad Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 30 Jan 2024 17:04:42 +0000 Subject: add tracing --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 25bc21f..de9b7ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ use poem::{ get, handler, listener::TcpListener, middleware::AddData, + middleware::Tracing, web::{Data, Path, Query}, EndpointExt, Route, Server, }; @@ -25,6 +26,7 @@ use rust_embed::RustEmbed; use error::BlossomError; use serde::Deserialize; +use tracing_subscriber::FmtSubscriber; type Result = std::result::Result; @@ -124,8 +126,12 @@ async fn custom_error(err: poem::Error) -> impl IntoResponse { #[tokio::main] async fn main() -> std::result::Result<(), std::io::Error> { + let subscriber = FmtSubscriber::new(); + tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); + // let mut skinny_data = mastodon_async::Data::default(); // skinny_data.base = Cow::from("https://skinnyver.se"); + let blossom = Route::new() .at("/", get(home)) .at("/blog", get(get_blog)) @@ -135,6 +141,7 @@ async fn main() -> std::result::Result<(), std::io::Error> { .at("/plants", get(plants)) .nest("/static/", EmbeddedFilesEndpoint::::new()) .catch_all_error(custom_error) + .with(Tracing) .with(AddData::new( reqwest::Client::builder() .connect_timeout(Duration::from_secs(1)) -- cgit