1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +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

@@ -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")?;