l0g
Opinionated l0gging facade meant for the no_std
libraries that are also sometimes used in a std
context.
Overview
Logging facilities differ depending on the environment, especially between no_std
and std
. This facade allows to delegate the decision which l0gging implementation shall be used to the top-level application.
Any call to l0g::{error,warn,info,debug,trace}
turns into a
- noop when no feature is set
log::{error,warn,info,debug,trace}
from the log crate whenlog
feature is setdefmt::{error,warn,info,debug,trace}
from the defmt crate whendefmt
feature is set
Moreover, proc-macro is provided to generalize over which formatting implementation should be used
turns into
if log
feature is used or
if defmt
feature is used.
This allows a {:?}
formatting to work, regardless of which logging implementation is chosen.
Usage
In the Cargo.toml
of your libraries just say
= "1"
In the no_std
top-level application specify the dependency with the defmt
feature. For how to make defmt
work, take a look into its respective documentation.
= { = "1", = ["defmt"] }
In the std top-level application specify the dependency with the log
feature. For how to make log
work, take a look into its respective documentation.
= { = "1", = ["log"] }