mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30: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,5 +1,5 @@
|
|||
use std::{
|
||||
io::{self, Write},
|
||||
io,
|
||||
path::PathBuf,
|
||||
process::{ExitCode, ExitStatus, Termination},
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ use compact_str::CompactString;
|
|||
use miette::{Diagnostic, Report};
|
||||
use thiserror::Error;
|
||||
use tokio::task;
|
||||
use tracing::{error, warn};
|
||||
|
||||
/// Error kinds emitted by cargo-binstall.
|
||||
#[derive(Error, Diagnostic, Debug)]
|
||||
|
@ -399,9 +400,9 @@ impl Termination for BinstallError {
|
|||
fn report(self) -> ExitCode {
|
||||
let code = self.exit_code();
|
||||
if let BinstallError::UserAbort = self {
|
||||
writeln!(io::stdout(), "Installation cancelled").ok();
|
||||
warn!("Installation cancelled");
|
||||
} else {
|
||||
writeln!(io::stderr(), "Fatal error:\n{:?}", Report::new(self)).ok();
|
||||
error!("Fatal error:\n{:?}", Report::new(self));
|
||||
}
|
||||
|
||||
code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue