mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-04 03:00:03 +00:00
Enable coloring in console log (#528)
* Enable feat ansi of dep tracing-subscriber * Rm use of `tracing_appender::non_blocking` since `cargo-binstall` is so simple that it doesn't need it. * Use `tracing::{error, info}` in `MainExit::report` * Use `tracing::{error, warn}` in `BinstallError::report` * Add dep supports-color v1.3.1 to crates/bin * Enable ansi of `tracing_subscriber::fmt` if stdout supports it Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
4e875874b6
commit
90495b35d8
6 changed files with 51 additions and 77 deletions
|
@ -1,6 +1,5 @@
|
|||
use std::{
|
||||
future::Future,
|
||||
io::{self, Write},
|
||||
process::{ExitCode, Termination},
|
||||
time::Duration,
|
||||
};
|
||||
|
@ -9,6 +8,7 @@ use binstalk::errors::BinstallError;
|
|||
use binstalk::helpers::{signal::cancel_on_user_sig_term, tasks::AutoAbortJoinHandle};
|
||||
use miette::Result;
|
||||
use tokio::runtime::Runtime;
|
||||
use tracing::{error, info};
|
||||
|
||||
pub enum MainExit {
|
||||
Success(Option<Duration>),
|
||||
|
@ -21,13 +21,13 @@ impl Termination for MainExit {
|
|||
match self {
|
||||
Self::Success(spent) => {
|
||||
if let Some(spent) = spent {
|
||||
writeln!(io::stdout(), "Done in {spent:?}").ok();
|
||||
info!("Done in {spent:?}");
|
||||
}
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
Self::Error(err) => err.report(),
|
||||
Self::Report(err) => {
|
||||
writeln!(io::stderr(), "Fatal error:\n{err:?}").ok();
|
||||
error!("Fatal error:\n{err:?}");
|
||||
ExitCode::from(16)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue