refactor(tvix/store/bin): condense subscriber setup a bit

We can use cli.json.then_some(…) to create a Some(…), allowing us to
omit the else { None } lines.

Change-Id: I6c8142a08d8cb88d6c8302e5ca7570698fcf2aa3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10505
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-12-31 16:44:57 +02:00 committed by clbot
parent f6d1a56c8c
commit 694ed7ea1a

View file

@ -162,24 +162,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let level = cli.log_level.unwrap_or(Level::INFO);
let subscriber = tracing_subscriber::registry()
.with(if cli.json {
Some(
.with(
cli.json.then_some(
tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr.with_max_level(level))
.json(),
)
} else {
None
})
.with(if !cli.json {
Some(
),
)
.with(
(!cli.json).then_some(
tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr.with_max_level(level))
.pretty(),
)
} else {
None
});
),
);
tracing::subscriber::set_global_default(subscriber).expect("Unable to set global subscriber");