From b9bc4d1ef710dcde625c7cf24293750168bbd225 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Thu, 31 Oct 2024 18:09:35 +1300 Subject: Print debug messages as info-level log messages Debug messages are now printed with a blue [INFO] prefix, to match the style of the information messages printed by the rest of the project. --- src/debug.rs | 5 +++-- src/emulators/graphical_emulator.rs | 4 ++-- src/emulators/headless_emulator.rs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/debug.rs b/src/debug.rs index 8be5bb9..17ed604 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -5,6 +5,7 @@ use std::time::Instant; const NORMAL: &str = "\x1b[0m"; +const BOLD: &str = "\x1b[1m"; const DIM: &str = "\x1b[2m"; const YELLOW: &str = "\x1b[33m"; const BLUE: &str = "\x1b[34m"; @@ -27,9 +28,9 @@ impl DebugState { } } - pub fn print(&self, string: &str) { + pub fn info(&self, string: &str) { if self.enabled { - println!("{}", string); + eprintln!("{BOLD}{BLUE}[INFO]{NORMAL}: {string}{NORMAL}"); } } diff --git a/src/emulators/graphical_emulator.rs b/src/emulators/graphical_emulator.rs index 8652aad..d298175 100644 --- a/src/emulators/graphical_emulator.rs +++ b/src/emulators/graphical_emulator.rs @@ -147,7 +147,7 @@ impl GraphicalEmulator { } Some(Signal::Halt) => { self.br.dev.loc.flush(); - self.debug.print("Program halted, exiting."); + self.debug.info("Program halted, exiting."); self.debug.debug_summary(&self.br.core); return EmulatorSignal::Halt; } @@ -286,7 +286,7 @@ impl WindowProgram for GraphicalEmulator { } Some(Signal::Halt) => { self.br.dev.loc.flush(); - self.debug.print("Program halted, exiting."); + self.debug.info("Program halted, exiting."); self.debug.debug_summary(&self.br.core); requests.write(Request::CloseWindow); break; diff --git a/src/emulators/headless_emulator.rs b/src/emulators/headless_emulator.rs index 03fbcf9..c508037 100644 --- a/src/emulators/headless_emulator.rs +++ b/src/emulators/headless_emulator.rs @@ -111,7 +111,7 @@ impl HeadlessEmulator { } Some(Signal::Halt) => { self.br.dev.loc.flush(); - self.debug.print("Program halted, exiting."); + self.debug.info("Program halted, exiting."); self.debug.debug_summary(&self.br.core); return EmulatorSignal::Halt; } -- cgit v1.2.3-70-g09d2