diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-10-31 18:09:35 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-10-31 18:11:11 +1300 |
commit | b9bc4d1ef710dcde625c7cf24293750168bbd225 (patch) | |
tree | ea6f97eb82b4edbcddc637772759bbf1942a110a | |
parent | dafa39853a6fc43f6a803ff6436b0f6d25373368 (diff) | |
download | bedrock-pc-b9bc4d1ef710dcde625c7cf24293750168bbd225.zip |
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.
-rw-r--r-- | src/debug.rs | 5 | ||||
-rw-r--r-- | src/emulators/graphical_emulator.rs | 4 | ||||
-rw-r--r-- | src/emulators/headless_emulator.rs | 2 |
3 files changed, 6 insertions, 5 deletions
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; } |