mirror of https://github.com/rapiz1/rathole.git
feat: emit colored log only when STDOUT is a tty
This commit is contained in:
parent
67192fbb9c
commit
e6dd0c8df8
|
@ -1507,6 +1507,7 @@ version = "0.3.4"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"atty",
|
||||
"backoff",
|
||||
"base64",
|
||||
"bincode",
|
||||
|
|
|
@ -69,6 +69,7 @@ base64 = { version = "0.13", optional = true }
|
|||
notify = { version = "5.0.0-pre.13", optional = true }
|
||||
console-subscriber = { version = "0.1", optional = true, features = ["parking_lot"] }
|
||||
const_format = "0.2"
|
||||
atty = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = { version = "6.0", default-features = false, features = ["build", "git", "cargo"] }
|
||||
|
|
|
@ -30,11 +30,14 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
#[cfg(not(feature = "console"))]
|
||||
{
|
||||
let is_atty = atty::is(atty::Stream::Stdout);
|
||||
|
||||
let level = "info"; // if RUST_LOG not present, use `info` level
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::from(level)),
|
||||
)
|
||||
.with_ansi(is_atty)
|
||||
.init();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue