flatland-client-lib 0.2.3

Flatland3 remote game client library (TCP session, bots, game state)
Documentation
//! Harvest / play-loop diagnostics.
//!
//! Enable verbose `info` logs: `FLATLAND_DEBUG_HARVEST=1`
//! Or filter in `RUST_LOG`: `flatland.harvest=debug`

pub const TARGET: &str = "flatland.harvest";

pub fn verbose() -> bool {
    static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
    *ON.get_or_init(|| {
        std::env::var("FLATLAND_DEBUG_HARVEST")
            .map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
            .unwrap_or(false)
    })
}

/// Log at `info` when [`verbose()`], else `debug` — always uses [`TARGET`].
#[macro_export]
macro_rules! harvest_trace {
    ($($arg:tt)*) => {
        if $crate::harvest_debug::verbose() {
            tracing::info!(target: $crate::harvest_debug::TARGET, $($arg)*);
        } else {
            tracing::debug!(target: $crate::harvest_debug::TARGET, $($arg)*);
        }
    };
}