1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Minor logging improvements

- only have colors if the output terminal is a tty
 - log in a non-blocking fashion
This commit is contained in:
Quentin Gliech
2022-01-26 17:21:54 +01:00
parent c3ac36190d
commit c7a243a3a1
3 changed files with 19 additions and 1 deletions

View File

@ -21,8 +21,10 @@ url = "2.2.2"
argon2 = { version = "0.3.2", features = ["password-hash"] }
reqwest = { version = "0.11.9", features = ["rustls-tls"], default-features = false, optional = true }
watchman_client = "0.7.1"
atty = "0.2.14"
tracing = "0.1.29"
tracing-appender = "0.2.0"
tracing-subscriber = { version = "0.3.6", features = ["env-filter"] }
tracing-opentelemetry = "0.16.0"
opentelemetry = { version = "0.16.0", features = ["trace", "metrics", "rt-tokio"] }

View File

@ -112,7 +112,10 @@ async fn try_main() -> anyhow::Result<()> {
// Setup logging
// This writes logs to stderr
let fmt_layer = tracing_subscriber::fmt::layer().with_writer(std::io::stderr);
let (log_writer, _guard) = tracing_appender::non_blocking(std::io::stderr());
let fmt_layer = tracing_subscriber::fmt::layer()
.with_writer(log_writer)
.with_ansi(atty::is(atty::Stream::Stderr));
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))
.context("could not setup logging filter")?;