1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00

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 <walters@verbum.org>
This commit is contained in:
Colin Walters
2023-02-12 11:30:53 -05:00
parent e2f808f42e
commit c07145a5aa
2 changed files with 15 additions and 3 deletions

View File

@@ -24,4 +24,4 @@ libc = "0.2.92"
tokio = { version = "1", features = ["macros"] }
log = "0.4.0"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

View File

@@ -5,7 +5,19 @@
use anyhow::Result;
async fn run() -> Result<()> {
tracing_subscriber::fmt::init();
// Don't include timestamps and such because they're not really useful and
// too verbose, and plus several log targets such as journald will already
// include timestamps.
let format = tracing_subscriber::fmt::format()
.without_time()
.with_target(false)
.compact();
// Log to stderr by default
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.event_format(format)
.with_writer(std::io::stderr)
.init();
tracing::trace!("starting");
bootc_lib::cli::run_from_iter(std::env::args()).await
}
@@ -13,7 +25,7 @@ async fn run() -> Result<()> {
#[tokio::main(flavor = "current_thread")]
async fn main() {
if let Err(e) = run().await {
eprintln!("error: {:#}", e);
tracing::error!("{:#}", e);
std::process::exit(1);
}
}