Crate rtt_logger

source ·
Expand description

A logger implementation to use RTT with the Rust log crate.

use log::{info, LevelFilter};
use rtt_logger::RTTLogger;
use rtt_target::rtt_init_print;

// logger configuration
const LOG_LEVEL: LevelFilter = LevelFilter::Info;
static LOGGER: RTTLogger = RTTLogger::new(LOG_LEVEL);

fn main() {
    // logger setup
    rtt_init_print!();
    log::set_logger(&LOGGER)
        .map(|()| log::set_max_level(LOG_LEVEL))
        .unwrap();

    // logger usage in main binary or in any library
    info!("Hello World!");
}

Structs

An RTT-based logger implementation.