forked from M-Labs/artiq
1
0
Fork 0

runtime: allow a much larger log buffer and avoid hacks.

This commit is contained in:
whitequark 2017-07-04 18:18:31 +00:00
parent 3ab8a4d505
commit ee1d5dbccb
3 changed files with 22 additions and 5 deletions

View File

@ -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)
}

View File

@ -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
}

View File

@ -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");