From ee1d5dbccb5110cbdddc86d1910e51a002299dae Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 4 Jul 2017 18:18:31 +0000 Subject: [PATCH] runtime: allow a much larger log buffer and avoid hacks. --- artiq/firmware/liblogger_artiq/lib.rs | 14 +++++++++++++- artiq/firmware/runtime/lib.rs | 2 +- artiq/firmware/runtime/mgmt.rs | 11 ++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/artiq/firmware/liblogger_artiq/lib.rs b/artiq/firmware/liblogger_artiq/lib.rs index c9cf3150a..fbaae4f47 100644 --- a/artiq/firmware/liblogger_artiq/lib.rs +++ b/artiq/firmware/liblogger_artiq/lib.rs @@ -59,14 +59,26 @@ impl BufferLogger { f(self.buffer.borrow_mut().extract()) } + pub fn max_log_level(&self) -> LogLevelFilter { + self.filter + .borrow() + .as_ref() + .expect("register the logger before touching maximum log level") + .get() + } + pub fn set_max_log_level(&self, max_level: LogLevelFilter) { self.filter .borrow() .as_ref() - .expect("register the logger before setting maximum log level") + .expect("register the logger before touching maximum log level") .set(max_level) } + pub fn uart_log_level(&self) -> LogLevelFilter { + self.uart_filter.get() + } + pub fn set_uart_log_level(&self, max_level: LogLevelFilter) { self.uart_filter.set(max_level) } diff --git a/artiq/firmware/runtime/lib.rs b/artiq/firmware/runtime/lib.rs index d62488153..c949220b8 100644 --- a/artiq/firmware/runtime/lib.rs +++ b/artiq/firmware/runtime/lib.rs @@ -176,7 +176,7 @@ pub extern fn main() -> i32 { panic!("out of memory"); }); - static mut LOG_BUFFER: [u8; 32768] = [0; 32768]; + static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17]; logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup); 0 } diff --git a/artiq/firmware/runtime/mgmt.rs b/artiq/firmware/runtime/mgmt.rs index 32fed0b2d..f1eff23c5 100644 --- a/artiq/firmware/runtime/mgmt.rs +++ b/artiq/firmware/runtime/mgmt.rs @@ -1,5 +1,6 @@ use std::io::{self, Read}; use logger_artiq::BufferLogger; +use log::LogLevelFilter; use sched::Io; use sched::{TcpListener, TcpStream}; use board; @@ -25,9 +26,13 @@ fn worker(mut stream: &mut TcpStream) -> io::Result<()> { match Request::read_from(stream)? { Request::GetLog => { BufferLogger::with_instance(|logger| { - logger.extract(|log| { + let old_log_level = logger.max_log_level(); + logger.set_max_log_level(LogLevelFilter::Off); + let result = logger.extract(|log| { Reply::LogContent(log).write_to(stream) - }) + }); + logger.set_max_log_level(old_log_level); + result })?; }, @@ -69,7 +74,7 @@ fn worker(mut stream: &mut TcpStream) -> io::Result<()> { } pub fn thread(io: Io) { - let listener = TcpListener::new(&io, 65535); + let listener = TcpListener::new(&io, 8192); listener.listen(1380).expect("mgmt: cannot listen"); info!("management interface active");