feat(tvix/cli): change log format to compact, add RUST_LOG support

This brings feature parity with the tvix-store CLI command, at least as
far as logging (not tracing) is concerned.

Alternative to cl/11482, RUST_LOG seems to be the more canonical way to
influence this, and is consistent with how it's done in tvix-store.

Change-Id: I923a0b0ae55dc49af7efdacdcf5b1f24e561b3c2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11527
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
This commit is contained in:
Florian Klink 2024-04-26 17:19:10 +03:00 committed by flokli
parent 88922bb207
commit 9401cccf84

View file

@ -5,6 +5,7 @@ use std::{fs, path::PathBuf};
use tracing::Level;
use tracing_subscriber::fmt::writer::MakeWriterExt;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use tracing_subscriber::{EnvFilter, Layer};
use tvix_build::buildservice;
use tvix_eval::builtins::impure_builtins;
use tvix_eval::observer::{DisassemblingObserver, TracingObserver};
@ -229,7 +230,13 @@ fn main() {
let subscriber = tracing_subscriber::registry().with(
tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr.with_max_level(level))
.pretty(),
.compact()
.with_filter(
EnvFilter::builder()
.with_default_directive(level.into())
.from_env()
.expect("invalid RUST_LOG"),
),
);
subscriber
.try_init()