From 8a171364794df244acb335558a208a628de9f94d Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 30 Dec 2024 22:57:57 +0300 Subject: kittybox-mf2: add tracing Change-Id: I9ed27cbf17ab65ec35ca45b36a4144296c7b6a6e --- src/bin/kittybox-mf2.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/bin/kittybox-mf2.rs b/src/bin/kittybox-mf2.rs index 85ebc6f..0cd89b4 100644 --- a/src/bin/kittybox-mf2.rs +++ b/src/bin/kittybox-mf2.rs @@ -26,6 +26,22 @@ enum Error { #[tokio::main] async fn main() -> Result<(), Error> { + use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry}; + + let tracing_registry = Registry::default() + .with(EnvFilter::from_default_env()) + .with( + #[cfg(debug_assertions)] + tracing_tree::HierarchicalLayer::new(2) + .with_bracketed_fields(true) + .with_indent_lines(true) + .with_verbose_exit(true), + #[cfg(not(debug_assertions))] + tracing_subscriber::fmt::layer().json() + .with_ansi(std::io::IsTerminal::is_terminal(&std::io::stdout().lock())) + ); + tracing_registry.init(); + let args = Args::parse(); let http: reqwest::Client = { -- cgit 1.4.1