Use tracing_subscriber::fmt::init() to install a global subscriber. This subscriber will be used by all threads for the remainder of the program's duration, similar to how the log crate works. The default configuration is based on the RUST_LOG environment variable.
use tracing::info;
use tracing_subscriber;
fn main() {
// install global subscriber configured based on RUST_LOG envvar.
tracing_subscriber::fmt::init();
let number_of_yaks = 3;
// this creates a new event, outside of any spans.
info!(number_of_yaks, "preparing to shave yaks");
let number_shaved = yak_shave::shave_all(number_of_yaks);
info!(
all_yaks_shaved = number_shaved == number_of_yaks,
"yak shaving completed."
);
}