macro_rules! log_enabled {
(logger: $logger:expr, target: $target:expr, $lvl:expr) => { ... };
(logger: $logger:expr, $lvl:expr) => { ... };
(target: $target:expr, $lvl:expr) => { ... };
($lvl:expr) => { ... };
}Expand description
Logging (docs/logging.md). day::info!("…") and friends are the log crate’s macros,
re-exported so an app needs no log dependency of its own for the common case. Because they
are log’s, anything that speaks log (env_logger, tracing-log, a hand-written
log::Log) works without adapters.
Day installs a default logger at launch, so these come out with no setup on every platform:
stderr natively, the browser console on web-dom. An app that wants something else calls
log::set_logger (or env_logger::init()) before day::launch and keeps it.
Determines if a message logged at the specified level in that module will
be logged.
This can be used to avoid expensive computation of log message arguments if the message would be ignored anyway.
§Examples
use log::{debug, log_enabled, Level};
if log_enabled!(Level::Debug) {
let data = expensive_call();
debug!("expensive debug data: {} {}", data.x, data.y);
}
if log_enabled!(target: "Global", Level::Debug) {
let data = expensive_call();
debug!(target: "Global", "expensive debug data: {} {}", data.x, data.y);
}
if log_enabled!(logger: my_logger, Level::Debug) {
let data = expensive_call();
debug!(target: "Global", "expensive debug data: {} {}", data.x, data.y);
}This macro accepts the same target and logger arguments as log.