Skip to content

Commit

Permalink
feat: max logs size
Browse files Browse the repository at this point in the history
  • Loading branch information
filipton committed Jan 10, 2025
1 parent 5d2a828 commit b1d3f56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/utils/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::cell::OnceCell;

pub const FILTER_MAX: log::LevelFilter = log::LevelFilter::Debug;
pub static mut GLOBAL_LOGS: OnceCell<Vec<String>> = OnceCell::new();
const MAX_LOGS_SIZE: usize = 100;

pub fn init_global_logs_store() {
unsafe {
Expand Down Expand Up @@ -68,6 +69,10 @@ impl log::Log for FkmLogger {
record.args(),
reset
));

if logs_buf.len() > MAX_LOGS_SIZE {
logs_buf.remove(0);
}
}
}
}
Expand Down

0 comments on commit b1d3f56

Please sign in to comment.