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 = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
"atty",
|
||||||
"backoff",
|
"backoff",
|
||||||
"base64",
|
"base64",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
|
|
@ -69,6 +69,7 @@ base64 = { version = "0.13", optional = true }
|
||||||
notify = { version = "5.0.0-pre.13", optional = true }
|
notify = { version = "5.0.0-pre.13", optional = true }
|
||||||
console-subscriber = { version = "0.1", optional = true, features = ["parking_lot"] }
|
console-subscriber = { version = "0.1", optional = true, features = ["parking_lot"] }
|
||||||
const_format = "0.2"
|
const_format = "0.2"
|
||||||
|
atty = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = { version = "6.0", default-features = false, features = ["build", "git", "cargo"] }
|
vergen = { version = "6.0", default-features = false, features = ["build", "git", "cargo"] }
|
||||||
|
|
|
@ -30,11 +30,14 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "console"))]
|
#[cfg(not(feature = "console"))]
|
||||||
{
|
{
|
||||||
|
let is_atty = atty::is(atty::Stream::Stdout);
|
||||||
|
|
||||||
let level = "info"; // if RUST_LOG not present, use `info` level
|
let level = "info"; // if RUST_LOG not present, use `info` level
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_env_filter(
|
.with_env_filter(
|
||||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::from(level)),
|
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::from(level)),
|
||||||
)
|
)
|
||||||
|
.with_ansi(is_atty)
|
||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue