| Crates.io | cfg_log |
| lib.rs | cfg_log |
| version | 0.1.1 |
| created_at | 2022-08-29 13:27:43.133303+00 |
| updated_at | 2022-08-29 17:58:40.370951+00 |
| description | Compile time conditional logging |
| homepage | |
| repository | https://github.com/FedericoStra/cfg_log |
| max_upload_size | |
| id | 654489 |
| size | 9,006 |
Compile time conditional logging.
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.