1
0
Fork 0
kirdy-firmware/src/device/log_setup.rs

35 lines
1.1 KiB
Rust

#[cfg(not(any(feature = "semihosting", feature = "RTT")))]
pub fn init_log() {
use super::usb;
static USB_LOGGER: usb::Logger = usb::Logger;
let _ = log::set_logger(&USB_LOGGER);
// log::set_max_level(log::LevelFilter::Debug);
log::set_max_level(log::LevelFilter::Trace);
}
#[cfg(feature = "RTT")]
pub fn init_log() {
use rtt_target::rtt_init_print;
use super::rtt_logger;
static RTT_LOGGER: rtt_logger::Logger = rtt_logger::Logger;
rtt_init_print!();
let _ = log::set_logger(&RTT_LOGGER);
log::set_max_level(log::LevelFilter::Debug);
}
#[cfg(feature = "semihosting")]
pub fn init_log() {
use cortex_m_log::{log::{init, Logger},
printer::semihosting::{hio::HStdout, InterruptOk}};
use log::LevelFilter;
static mut LOGGER: Option<Logger<InterruptOk<HStdout>>> = None;
let logger = Logger {
inner: InterruptOk::<_>::stdout().expect("semihosting stdout"),
level: LevelFilter::Info,
};
let logger = unsafe { LOGGER.get_or_insert(logger) };
init(logger).expect("set logger");
}