Tracing
Tracing is a library for logging. It consists of multiple libraries. You need at least tracing, which is the base of the logging system, and tracing_subscriber, which defines the subscriber of the tracing messages.
# To install
cargo add tracing tracing_subscriber
# I recommend the use of the env filter
cargo add tracing tracing_subscriber --features env-filter
Setup
First you need to setup how the tracing messages are subscribed/used. You can setup a basic logging using the following code:
tracing_subscriber::fmt()
.with_target(false)
.with_level(true)
.compact()
.init();
# Or optional with the default env filter
tracing_subscriber::fmt()
.with_target(false)
.with_level(true)
.with_env_filter(EnvFilter::default)from_default_env())
.compact()
.init();