From cd561b19ef411c296c86afc6f0df4f39caa1c9e9 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 16 Aug 2022 01:20:07 -0400 Subject: [PATCH] Allow rtos_trace example to be used without log --- examples/nrf/Cargo.toml | 3 +-- examples/nrf/src/bin/rtos_trace.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 2f877b6a..8704f27c 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -35,7 +35,6 @@ log = [ rtos-trace = [ "dep:rtos-trace", "dep:systemview-target", - "log", "embassy-executor/rtos-trace", "embassy-executor/rtos-trace-interrupt", ] @@ -68,7 +67,7 @@ log = { version = "0.4.17", optional = true } [[bin]] name = "rtos_trace" -required-features = ["nightly", "rtos-trace", "log"] +required-features = ["nightly", "rtos-trace"] [patch.crates-io] rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf/src/bin/rtos_trace.rs index 8b4f5b75..461e174c 100644 --- a/examples/nrf/src/bin/rtos_trace.rs +++ b/examples/nrf/src/bin/rtos_trace.rs @@ -13,6 +13,7 @@ use embassy_nrf::Peripherals; use rtos_trace; use systemview_target::SystemView; use panic_probe as _; +#[cfg(feature = "log")] use log::*; static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); @@ -31,7 +32,10 @@ rtos_trace::global_application_callbacks!{TraceInfo} #[embassy_executor::task] async fn run1() { loop { + #[cfg(feature = "log")] info!("DING DONG"); + #[cfg(not(feature = "log"))] + rtos_trace::trace::marker(13); Timer::after(Duration::from_ticks(16000)).await; } } @@ -55,8 +59,11 @@ async fn run3() { #[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { LOGGER.init(); - ::log::set_logger(&LOGGER).ok(); - ::log::set_max_level(::log::LevelFilter::Trace); + #[cfg(feature = "log")] + { + ::log::set_logger(&LOGGER).ok(); + ::log::set_max_level(::log::LevelFilter::Trace); + } spawner.spawn(run1()).unwrap(); spawner.spawn(run2()).unwrap();