veecle_osal_embassy/
log.rs

1//! Logging related system utilities.
2
3pub use veecle_osal_api::log::LogTarget;
4
5#[cfg(not(target_os = "none"))]
6use std::io::Write;
7
8/// Implements the [`LogTarget`] trait.
9#[derive(Debug)]
10pub struct Log;
11
12impl LogTarget for Log {
13    type Time = crate::time::Time;
14
15    fn init() {
16        #[cfg(target_os = "none")]
17        rtt_target::rtt_init_print!();
18    }
19
20    fn println(args: core::fmt::Arguments<'_>) {
21        #[cfg(not(target_os = "none"))]
22        // this is a logger, ignore any errors writing
23        let _ = std::writeln!(std::io::stdout(), "{args}");
24
25        #[cfg(target_os = "none")]
26        // `"{args}"` _would_ work, except `rtt_target::rprintln!` has a buggy macro arm that bypasses the formatting
27        // infrastructure on a single expression.
28        rtt_target::rprintln!("{}", args);
29    }
30}