bme280-rs 0.4.1

A crate to query BME280 sensors over I²C
Documentation
// Copyright Claudio Mattera 2022-2026.
//
// Distributed under the MIT License or the Apache 2.0 License at your option.
// See the accompanying files LICENSE-MIT.txt and LICENSE-APACHE-2.0.txt, or
// online at
// https://opensource.org/licenses/MIT
// https://opensource.org/licenses/Apache-2.0

//! Logging macros
//!
//! If the feature `log` is enabled, then logging is done with macros from
//! crate [`log`](https://crates.io/crates/log).
//!
//! If the feature `defmt` is enabled, then logging is done with macros from
//! crate [`defmt`](https://crates.io/crates/defmt).
//!
//! If neither features are enabled, logging is done with no-op macros,
//! effectively disabling logging.
//!
//! If both features are enabled, logging is done with macros from both crates.
//! This is probably undesired, but it makes features additive.

// Just log

#[cfg(all(feature = "log", not(feature = "defmt")))]
pub(crate) use log::debug;

#[cfg(all(feature = "log", not(feature = "defmt")))]
pub(crate) use log::warn;

// Just defmt

#[cfg(all(feature = "defmt", not(feature = "log")))]
pub(crate) use defmt::debug;

#[cfg(all(feature = "defmt", not(feature = "log")))]
pub(crate) use defmt::warn;

// Neither log not defmt, logging is a no-op

#[cfg(not(any(feature = "log", feature = "defmt")))]
/// No-op debug macro
macro_rules! debug {
    ($($arg:tt)+) => {};
}

#[cfg(not(any(feature = "log", feature = "defmt")))]
pub(crate) use debug;

#[cfg(not(any(feature = "log", feature = "defmt")))]
/// No-op warn macro
macro_rules! warn_ {
    ($($arg:tt)+) => {};
}

#[cfg(not(any(feature = "log", feature = "defmt")))]
pub(crate) use warn_ as warn;

// Both log and defmt, use both

#[cfg(all(feature = "log", feature = "defmt"))]
/// Both debug macro
macro_rules! debug {
    ($($arg:tt)+) => {
        ::log::debug!($($arg)+);
        ::defmt::debug!($($arg)+)
    };
}

#[cfg(all(feature = "log", feature = "defmt"))]
pub(crate) use debug;

#[cfg(all(feature = "log", feature = "defmt"))]
/// Both warn macro
macro_rules! warn_ {
    ($($arg:tt)+) => {
        ::log::warn!($($arg)+);
        ::defmt::warn!($($arg)+)
    };
}

#[cfg(all(feature = "log", feature = "defmt"))]
pub(crate) use warn_ as warn;