diff --git a/Cargo.toml b/Cargo.toml index 03ec669..3406b12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.41", features = ["full"] } toml = "0.8" -#tracing= "0.1" -#tracing-subscriber = "0.3" +tracing= "0.1" +tracing-subscriber = "0.3" [dev-dependencies] assert2 = "0.3" diff --git a/src/lib.rs b/src/lib.rs index 09e1b09..d81568a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,8 @@ use nextcloud::DeckClient; #[derive(Parser, Debug)] #[clap(version = clap::crate_version!(), author = clap::crate_authors!(), about = clap::crate_description!())] struct Commands { + #[clap(long, action = clap::ArgAction::SetTrue)] + log: bool, #[clap(subcommand)] command: Command, } @@ -130,6 +132,15 @@ pub async fn run(ctx: Ctx) -> color_eyre::Result<()> { color_eyre::install()?; let commands = Commands::parse(); + if commands.log { + tracing::subscriber::set_global_default( + tracing_subscriber::FmtSubscriber::builder() + .with_max_level(tracing::Level::TRACE) + .finish(), + )?; + tracing::info!("ready"); + } + let cfg = AppConfig::load(&ctx); match cfg { Err(err) => {