diff --git a/src/runtime2/runtime.rs b/src/runtime2/runtime.rs index 55d417635e1d733cd1ece961abb76d58d41b0921..bf954b4cdea2ede7f5efb75fef397e823e46f962 100644 --- a/src/runtime2/runtime.rs +++ b/src/runtime2/runtime.rs @@ -14,9 +14,9 @@ use super::scheduler::*; #[derive(PartialOrd, PartialEq, Copy, Clone)] pub enum LogLevel { - None, // no logging Debug, // all logging (includes messages) Info, // rough logging + None, // no logging } // ----------------------------------------------------------------------------- diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index f901b0056d7863cb7be09f9e2fe541017fdbad89..4aea4d03e2928f658de0827159de084f48b5e5dc 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -34,13 +34,13 @@ impl<'a> SchedulerCtx<'a> { pub(crate) fn debug(&self, text: &str) { // TODO: Probably not always use colour - if self.log_level >= LogLevel::Debug { - println!("[s:{:02}, c:{:03}] \x1b[0;34m{}\x1b[0m", self.id, self.comp, text); + if LogLevel::Debug >= self.log_level { + println!("[s:{:02}, c:{:03}] \x1b[0;36m{}\x1b[0m", self.id, self.comp, text); } } pub(crate) fn info(&self, text: &str) { - if self.log_level >= LogLevel::Info { + if LogLevel::Info >= self.log_level { println!("[s:{:02}, c:{:03}] {}", self.id, self.comp, text); } } diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index 138fccfa2ee5e323b3348452eec5069438a1044b..6baa362a0c2dd9fc572b89a4c7b005151ed2f6ac 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -5,13 +5,13 @@ use crate::runtime2::component::{CompCtx, CompPDL}; mod error_handling; +const LOG_LEVEL: LogLevel = LogLevel::Debug; const NUM_THREADS: u32 = 4; -const DEBUG_LOGGING: bool = true; pub(crate) fn compile_and_create_component(source: &str, routine_name: &str, args: ValueGroup) { let protocol = ProtocolDescription::parse(source.as_bytes()) .expect("successful compilation"); - let runtime = Runtime::new(NUM_THREADS, DEBUG_LOGGING, protocol) + let runtime = Runtime::new(NUM_THREADS, LOG_LEVEL, protocol) .expect("successful runtime startup"); create_component(&runtime, "", routine_name, args); } @@ -37,7 +37,7 @@ fn test_component_creation() { auto b = 5 + a; } ").expect("compilation"); - let rt = Runtime::new(1, true, pd).unwrap(); + let rt = Runtime::new(1, LOG_LEVEL, pd).unwrap(); for _i in 0..20 { create_component(&rt, "", "nothing_at_all", no_args()); @@ -94,7 +94,7 @@ fn test_component_communication() { new sender(o_mrmm, 5, 5); new receiver(i_mrmm, 5, 5); }").expect("compilation"); - let rt = Runtime::new(3, true, pd).unwrap(); + let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor", no_args()); } @@ -143,7 +143,7 @@ fn test_intermediate_messenger() { new constructor_template(); } ").expect("compilation"); - let rt = Runtime::new(3, true, pd).unwrap(); + let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor", no_args()); } @@ -193,7 +193,7 @@ fn test_simple_select() { new sender(tx_b, num_sends); } ").expect("compilation"); - let rt = Runtime::new(3, true, pd).unwrap(); + let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor", no_args()); } @@ -215,7 +215,7 @@ fn test_unguarded_select() { } } ").expect("compilation"); - let rt = Runtime::new(3, false, pd).unwrap(); + let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor_outside_select", no_args()); create_component(&rt, "", "constructor_inside_select", no_args()); } @@ -231,7 +231,7 @@ fn test_empty_select() { } } ").expect("compilation"); - let rt = Runtime::new(3, false, pd).unwrap(); + let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor", no_args()); } @@ -257,7 +257,7 @@ fn test_random_u32_temporary_thingo() { new random_taker(rx, num_values); } ").expect("compilation"); - let rt = Runtime::new(1, true, pd).unwrap(); + let rt = Runtime::new(1, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "constructor", no_args()); } @@ -387,6 +387,6 @@ fn test_sending_receiving_union() { new client(cmd_tx, data_rx, num_rounds); } ").expect("compilation"); - let rt = Runtime::new(1, false, pd).unwrap(); + let rt = Runtime::new(1, LOG_LEVEL, pd).unwrap(); create_component(&rt, "", "main", no_args()); } \ No newline at end of file