Skip to content

Instantly share code, notes, and snippets.

@mtthw-meyer
Created July 23, 2020 16:16
Show Gist options
  • Save mtthw-meyer/0c1d4977cfbb848916f92830c35c852c to your computer and use it in GitHub Desktop.
Save mtthw-meyer/0c1d4977cfbb848916f92830c35c852c to your computer and use it in GitHub Desktop.
use log::{Record, Level, Metadata};
#[cfg(any(feature = "rtt"))]
use rtt_target::{rprintln, rtt_init_print};
pub struct Logger;
impl Logger {
pub fn init(&self) {
#[cfg(any(feature = "rtt"))]
rtt_init_print!();
}
}
impl log::Log for Logger {
fn enabled(&self, metadata: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
#[cfg(any(feature = "rtt"))]
rprintln!("{} - {}", record.level(), record.args());
}
fn flush(&self) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment