From 2ae30b5a955ec1c356f610679eba8ef51863c11a Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 6 Oct 2016 10:56:19 +0000 Subject: [PATCH] Rust: aggregate kernel CPU log messages and print line by line. --- artiq/runtime.rs/src/session.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/artiq/runtime.rs/src/session.rs b/artiq/runtime.rs/src/session.rs index f549c90a7..0cb6fb7e5 100644 --- a/artiq/runtime.rs/src/session.rs +++ b/artiq/runtime.rs/src/session.rs @@ -55,7 +55,8 @@ enum KernelState { struct Session<'a> { congress: &'a mut Congress, kernel_state: KernelState, - watchdog_set: clock::WatchdogSet + watchdog_set: clock::WatchdogSet, + log_buffer: String } impl<'a> Session<'a> { @@ -63,7 +64,8 @@ impl<'a> Session<'a> { Session { congress: congress, kernel_state: KernelState::Absent, - watchdog_set: clock::WatchdogSet::new() + watchdog_set: clock::WatchdogSet::new(), + log_buffer: String::new() } } @@ -286,8 +288,16 @@ fn process_kern_message(waiter: Waiter, trace!("comm<-kern {:?}", request); match request { kern::Log(log) => { - info!(target: "kernel", "{}", log); - kern_acknowledge() + session.log_buffer += log; + try!(kern_acknowledge()); + + if &log[log.len() - 1..] == "\n" { + for line in session.log_buffer.lines() { + info!(target: "kernel", "{}", line); + } + session.log_buffer.clear() + } + Ok(()) } kern::NowInitRequest =>