cfg_log 0.1.1

Compile time conditional logging
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented1 out of 1 items with examples
  • Size
  • Source code size: 8.69 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.17 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • FedericoStra/cfg_log
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FedericoStra

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.