Skip to content

Commit c07145a

Browse files
committed
Tweak default tracing output
Do log `info` level by default, but quiet the output format. Prep for more use of tracing. Signed-off-by: Colin Walters <[email protected]>
1 parent e2f808f commit c07145a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ libc = "0.2.92"
2424
tokio = { version = "1", features = ["macros"] }
2525
log = "0.4.0"
2626
tracing = "0.1"
27-
tracing-subscriber = "0.3"
27+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

cli/src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@
55
use anyhow::Result;
66

77
async fn run() -> Result<()> {
8-
tracing_subscriber::fmt::init();
8+
// Don't include timestamps and such because they're not really useful and
9+
// too verbose, and plus several log targets such as journald will already
10+
// include timestamps.
11+
let format = tracing_subscriber::fmt::format()
12+
.without_time()
13+
.with_target(false)
14+
.compact();
15+
// Log to stderr by default
16+
tracing_subscriber::fmt()
17+
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
18+
.event_format(format)
19+
.with_writer(std::io::stderr)
20+
.init();
921
tracing::trace!("starting");
1022
bootc_lib::cli::run_from_iter(std::env::args()).await
1123
}
1224

1325
#[tokio::main(flavor = "current_thread")]
1426
async fn main() {
1527
if let Err(e) = run().await {
16-
eprintln!("error: {:#}", e);
28+
tracing::error!("{:#}", e);
1729
std::process::exit(1);
1830
}
1931
}

0 commit comments

Comments
 (0)