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

Equivalent to log::debug! if the feature log is enabled, discarded otherwise.

Equivalent to log::error! if the feature log is enabled, discarded otherwise.

Equivalent to log::info! if the feature log is enabled, discarded otherwise.

Equivalent to log::log! if the feature log is enabled, discarded otherwise.

Equivalent to log::log_enabled! if the feature log is enabled, false otherwise.

Equivalent to log::trace! if the feature log is enabled, discarded otherwise.

Equivalent to log::warn! if the feature log is enabled, discarded otherwise.