2 releases

Uses new Rust 2021

0.1.1 Aug 29, 2022
0.1.0 Aug 29, 2022

#187 in Debugging

Download history 20/week @ 2022-08-23 18/week @ 2022-08-30 9/week @ 2022-09-06 20/week @ 2022-09-13 8/week @ 2022-09-20

75 downloads per month
Used in texfmt

MIT license

7KB
55 lines

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.

No runtime deps