feat: enable trace logging support

This commit is contained in:
Paul Campbell 2024-12-08 10:51:19 +00:00
parent 6832c22d3d
commit fd8ba06210
2 changed files with 13 additions and 2 deletions

View file

@ -20,8 +20,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
tokio = { version = "1.41", features = ["full"] } tokio = { version = "1.41", features = ["full"] }
toml = "0.8" toml = "0.8"
#tracing= "0.1" tracing= "0.1"
#tracing-subscriber = "0.3" tracing-subscriber = "0.3"
[dev-dependencies] [dev-dependencies]
assert2 = "0.3" assert2 = "0.3"

View file

@ -27,6 +27,8 @@ use nextcloud::DeckClient;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap(version = clap::crate_version!(), author = clap::crate_authors!(), about = clap::crate_description!())] #[clap(version = clap::crate_version!(), author = clap::crate_authors!(), about = clap::crate_description!())]
struct Commands { struct Commands {
#[clap(long, action = clap::ArgAction::SetTrue)]
log: bool,
#[clap(subcommand)] #[clap(subcommand)]
command: Command, command: Command,
} }
@ -130,6 +132,15 @@ pub async fn run(ctx: Ctx) -> color_eyre::Result<()> {
color_eyre::install()?; color_eyre::install()?;
let commands = Commands::parse(); 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); let cfg = AppConfig::load(&ctx);
match cfg { match cfg {
Err(err) => { Err(err) => {