Skip to content

Instantly share code, notes, and snippets.

@bobmcwhirter
Created August 21, 2020 20:25
Show Gist options
  • Select an option

  • Save bobmcwhirter/7105bd3a0091b36c631e97f32d128cb1 to your computer and use it in GitHub Desktop.

Select an option

Save bobmcwhirter/7105bd3a0091b36c631e97f32d128cb1 to your computer and use it in GitHub Desktop.
16:23:55.925 INFO - about to panic
#![no_std]
use log::{
Metadata,
Record
};
use rtt_target::rprintln;
pub struct RTTLogger;
impl log::Log for RTTLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
if self.enabled(record.metadata()) {
rprintln!("{} - {}", record.level(), record.args());
}
}
fn flush(&self) {
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
info!("about to panic");
panic!("well dang");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment