From 27273967cbf85581ebc638dc6b71928f4016f069 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Kazuhiro Date: Mon, 22 Apr 2024 10:15:01 +0900 Subject: [PATCH] kble: introduce tracing-subscriber --- Cargo.lock | 2 ++ kble/Cargo.toml | 2 ++ kble/src/main.rs | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index db4cb82..0f65006 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,6 +770,8 @@ dependencies = [ "serde_yaml", "tokio", "tokio-tungstenite", + "tracing", + "tracing-subscriber", "url", ] diff --git a/kble/Cargo.toml b/kble/Cargo.toml index 95fbcd8..54cf675 100644 --- a/kble/Cargo.toml +++ b/kble/Cargo.toml @@ -24,5 +24,7 @@ clap.workspace = true serde.workspace = true serde_yaml = "0.9" serde_with = "3.6" +tracing-subscriber.workspace = true +tracing.workspace = true notalawyer.workspace = true notalawyer-clap.workspace = true diff --git a/kble/src/main.rs b/kble/src/main.rs index 86f1897..09862eb 100644 --- a/kble/src/main.rs +++ b/kble/src/main.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use anyhow::{Context, Result}; use clap::Parser; use notalawyer_clap::*; +use tracing_subscriber::{prelude::*, EnvFilter}; mod app; mod plug; @@ -33,6 +34,15 @@ impl Args { #[tokio::main] async fn main() -> Result<()> { + tracing_subscriber::registry() + .with( + tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_writer(std::io::stderr), + ) + .with(EnvFilter::from_default_env()) + .init(); + let args = Args::parse_with_license_notice(include_notice!()); let config = args.load_spaghetti_config()?; app::run(&config).await?;