From b1d3f56df6cb120f44407050d058dc9399c2ada8 Mon Sep 17 00:00:00 2001 From: filipton Date: Fri, 10 Jan 2025 15:06:37 +0100 Subject: [PATCH] feat: max logs size --- src/main.rs | 5 ----- src/utils/logger.rs | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index fefd6c2..c1fab17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -279,11 +279,6 @@ async fn main(spawner: Spawner) { set_brownout_detection(true); global_state.state.lock().await.scene = Scene::WaitingForCompetitor; - log::info!("Heap info:"); - log::info!("Size: {}", esp_alloc::HEAP.used() + esp_alloc::HEAP.free()); - log::info!("Used: {}", esp_alloc::HEAP.used()); - log::info!("Free: {}", esp_alloc::HEAP.free()); - let mut counter = 0; loop { counter += 1; diff --git a/src/utils/logger.rs b/src/utils/logger.rs index e660b5a..8d5bd6c 100644 --- a/src/utils/logger.rs +++ b/src/utils/logger.rs @@ -4,6 +4,7 @@ use core::cell::OnceCell; pub const FILTER_MAX: log::LevelFilter = log::LevelFilter::Debug; pub static mut GLOBAL_LOGS: OnceCell> = OnceCell::new(); +const MAX_LOGS_SIZE: usize = 100; pub fn init_global_logs_store() { unsafe { @@ -68,6 +69,10 @@ impl log::Log for FkmLogger { record.args(), reset )); + + if logs_buf.len() > MAX_LOGS_SIZE { + logs_buf.remove(0); + } } } }