Skip to main content

skipper_core/
logger.rs

1/// True when `SKIPPER_DEBUG` is set to a non-empty value.
2pub fn debug_enabled() -> bool {
3    std::env::var("SKIPPER_DEBUG").is_ok_and(|v| !v.is_empty())
4}
5
6/// Debug log to stderr, only when `SKIPPER_DEBUG` is set.
7pub fn log(msg: impl AsRef<str>) {
8    if debug_enabled() {
9        eprintln!("[skipper] {}", msg.as_ref());
10    }
11}
12
13/// Warning to stderr, only when `SKIPPER_DEBUG` is set.
14pub fn warn(msg: impl AsRef<str>) {
15    if debug_enabled() {
16        eprintln!("[skipper] WARN: {}", msg.as_ref());
17    }
18}