Skip to content

Commit

Permalink
Execute update debug output function in app loop
Browse files Browse the repository at this point in the history
This makes the channel doesn't fill up if the current screen isn't on debug pane
  • Loading branch information
AS1100K committed Jan 18, 2025
1 parent 8e4f036 commit c86cf1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/monitors/cu_consolemon/src/debug_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl DebugLog {
}

pub fn get_logs(&mut self) -> String {
self.update_logs();
self.debug_log.join_compact("").to_string()
}
}
Expand Down Expand Up @@ -101,10 +100,21 @@ impl Log for LogSubscriber {
}

pub trait UIExt {
fn update_debug_output(&mut self);

fn draw_debug_output(&mut self, f: &mut Frame, area: Rect);
}

impl UIExt for UI {
fn update_debug_output(&mut self) {
let mut error_buffer = String::new();
self.error_redirect
.read_to_string(&mut error_buffer)
.unwrap();
self.debug_output.push_logs(error_buffer);
self.debug_output.update_logs();
}

fn draw_debug_output(&mut self, f: &mut Frame, area: Rect) {
let mut error_buffer = String::new();
self.error_redirect
Expand Down
3 changes: 3 additions & 0 deletions components/monitors/cu_consolemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ impl UI {

fn run_app<B: Backend>(&mut self, terminal: &mut Terminal<B>) -> io::Result<()> {
loop {
#[cfg(feature = "debug_pane")]
self.update_debug_output();

terminal.draw(|f| {
self.draw(f);
})?;
Expand Down

0 comments on commit c86cf1a

Please sign in to comment.