add tracing
This commit is contained in:
parent
9ae0630db4
commit
a06790a2af
7 changed files with 413 additions and 17 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -3,13 +3,14 @@ use std::process::ExitCode;
|
|||
use std::{error::Error as StdError, sync::Arc};
|
||||
|
||||
use clap::{ColorChoice, Parser as _};
|
||||
use tracing_human_layer::HumanLayer;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::{EnvFilter, layer::SubscriberExt};
|
||||
|
||||
fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
|
||||
let args = Arc::new(dynix::Args::parse());
|
||||
|
||||
dbg!(&args);
|
||||
|
||||
let success = dynix::CLI_ENABLE_COLOR.set(match args.color {
|
||||
let success = dynix::_CLI_ENABLE_COLOR.set(match args.color {
|
||||
ColorChoice::Always => true,
|
||||
ColorChoice::Auto => io::stdin().is_terminal(),
|
||||
ColorChoice::Never => false,
|
||||
|
|
@ -18,6 +19,13 @@ fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
|
|||
success.expect("logic error in CLI_ENABLE_COLOR");
|
||||
}
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(HumanLayer::new().with_color_output(*dynix::SHOULD_COLOR))
|
||||
.with(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
tracing::debug!("Parsed command-line arguments: {args:?}");
|
||||
|
||||
use dynix::args::Subcommand::*;
|
||||
match &args.subcommand {
|
||||
Append(append_args) => dynix::do_append(args.clone(), append_args.clone())?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue