Skip to content

Commit

Permalink
Make debug_pane work with balancebot
Browse files Browse the repository at this point in the history
  • Loading branch information
AS1100K committed Jan 19, 2025
1 parent f586e78 commit ee96cdc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions components/monitors/cu_consolemon/src/debug_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
std::sync::mpsc::{Receiver, SyncSender},
};

#[derive(Debug)]
pub struct DebugLog {
debug_log: VecDeque<String>,
pub(crate) max_rows: AtomicU16,
Expand Down Expand Up @@ -74,8 +75,10 @@ impl LogSubscriber {
#[allow(dead_code)]
pub fn new(tx: SyncSender<String>) -> Self {
let log_subscriber = Self { tx };
log::set_boxed_logger(Box::new(log_subscriber.clone())).unwrap();
log::set_max_level(LevelFilter::Info);
if log::set_boxed_logger(Box::new(log_subscriber.clone())).is_err() {
eprintln!("Failed to set `LogSubscriber` as global log subscriber")
}
log::set_max_level(LevelFilter::Debug);
log_subscriber
}

Expand Down
4 changes: 2 additions & 2 deletions components/monitors/cu_consolemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ impl CuMonitor for CuConsoleMon {
let max_lines = terminal.size().unwrap().height - 5;
let (debug_log, tx) = debug_pane::DebugLog::new(max_lines);

#[allow(unused_variables)]
let log_subscriber = debug_pane::LogSubscriber::new(tx);

*cu29_log_runtime::EXTRA_TEXT_LOGGER.write().unwrap() =
Expand All @@ -661,8 +660,9 @@ impl CuMonitor for CuConsoleMon {
setup_terminal();

ui.debug_output = Some(debug_log);
} else {
println!("EXTRA_TEXT_LOGGER is none");
}

ui.run_app(&mut terminal).expect("Failed to run app");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/cu_rp_balancebot/src/resim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn main() {
let copper_ctx = basic_copper_setup(
&PathBuf::from(logger_path),
LOG_SLAB_SIZE,
false,
true,
Some(robot_clock.clone()),
)
.expect("Failed to setup logger.");
Expand Down
2 changes: 1 addition & 1 deletion examples/cu_rp_balancebot/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn setup_copper(mut commands: Commands) {
let copper_ctx = basic_copper_setup(
&PathBuf::from(logger_path),
LOG_SLAB_SIZE,
false,
true,
Some(robot_clock.clone()),
)
.expect("Failed to setup logger.");
Expand Down

0 comments on commit ee96cdc

Please sign in to comment.