Expand description
Compile time conditional logging.
The cfg_log
crate provides a way to conditionally use the logging macros from the
log
crate depending on whether the log
feature of the main crate is enabled or not.
Suppose the Cargo.toml
file of a crate using cfg_log
contains
[dependencies]
cfg_log = "0.1.0"
log = { version = "0.4.17", optional = true }
Then the code
use cfg_log::*;
fn main() {
debug!("the answer is {}", 42);
}
is equivalent to
#[cfg(feature = "log")]
use log::*;
fn main() {
#[cfg(feature = "log")]
debug!("the answer is {}", 42);
}
Macrosยง
- debug
- Equivalent to
log::debug!
if the featurelog
is enabled, discarded otherwise. - error
- Equivalent to
log::error!
if the featurelog
is enabled, discarded otherwise. - info
- Equivalent to
log::info!
if the featurelog
is enabled, discarded otherwise. - log
- Equivalent to
log::log!
if the featurelog
is enabled, discarded otherwise. - log_
enabled - Equivalent to
log::log_enabled!
if the featurelog
is enabled,false
otherwise. - trace
- Equivalent to
log::trace!
if the featurelog
is enabled, discarded otherwise. - warn
- Equivalent to
log::warn!
if the featurelog
is enabled, discarded otherwise.