#![warn(missing_docs)]
#![no_std]
#[cfg(feature = "log")]
mod rust_log;
#[cfg(all(feature = "std", not(any(all(target_arch = "wasm32", target_os = "unknown"), target_os = "android"))))]
mod time;
mod data;
mod out;
mod rt;
#[doc(hidden)]
pub use out::Out;
#[cfg(feature = "ufmt")]
mod ufmt;
#[cfg(not(feature = "ufmt"))]
mod cor;
#[cfg(feature = "ufmt")]
use crate::ufmt::derive::uDebug as Debug;
use core::sync::atomic::{AtomicU8, Ordering};
static LEVEL: AtomicU8 = AtomicU8::new(0);
#[repr(u8)]
#[derive(Copy, Eq, Debug)]
pub enum Level {
#[doc(hidden)]
NONE = 0,
ERROR = 1,
WARN,
INFO,
DEBUG,
TRACE,
}
impl Clone for Level {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl PartialEq for Level {
#[inline]
fn eq(&self, other: &Self) -> bool {
*self as u8 == *other as u8
}
}
pub fn set_level(level: Level) {
rt::init();
LEVEL.store(level as u8, Ordering::Relaxed);
#[cfg(feature = "log")]
{
rust_log::init(level.into());
}
}
#[inline]
pub fn is_enabled(level: Level) -> bool {
LEVEL.load(Ordering::Relaxed) >= level as u8
}