cfg_log

Crates.iocfg_log
lib.rscfg_log
version0.1.1
sourcesrc
created_at2022-08-29 13:27:43.133303
updated_at2022-08-29 17:58:40.370951
descriptionCompile time conditional logging
homepage
repositoryhttps://github.com/FedericoStra/cfg_log
max_upload_size
id654489
size9,006
Federico Stra (FedericoStra)

documentation

README

cfg_log

Compile time conditional logging.

GitHub Crates.io docs.rs MIT license GitHub Workflow Status Lines of code

Usage

The main crate should depend on cfg_log and optionally on log.

[dependencies]
cfg_log = "0.1.0"
log = { version = "0.4.17", optional = true }

Then logging can be done more concisely with

use cfg_log::*;

fn main() {
    debug!("the answer is {}", 42);
}

instead of

#[cfg(feature = "log")]
use log::*;

fn main() {
    #[cfg(feature = "log")]
    debug!("the answer is {}", 42);
}

The debug! macro will automatically expand to log::debug! if the log feature is enabled, or it will be discarded at compile time otherwise.

See test_cfg_log for an example package.

Commit count: 9

cargo fmt