pub struct RuntimeLogger;
impl RuntimeLogger {
#[cfg(feature = "std")]
pub fn init() {}
#[cfg(not(feature = "std"))]
pub fn init() {
static LOGGER: RuntimeLogger = RuntimeLogger;
let _ = log::set_logger(&LOGGER);
log::set_max_level(crate::io::logging::max_level().into());
}
}
impl log::Log for RuntimeLogger {
fn enabled(&self, _: &log::Metadata) -> bool {
true
}
fn log(&self, record: &log::Record) {
use ::core::fmt::Write;
let mut msg = alloc::string::String::default();
let _ = ::core::write!(&mut msg, "{}", record.args());
crate::io::logging::log(record.level().into(), record.target(), msg.as_bytes());
}
fn flush(&self) {}
}