mirror of https://github.com/m-labs/artiq.git
runtime: allow a much larger log buffer and avoid hacks.
This commit is contained in:
parent
3ab8a4d505
commit
ee1d5dbccb
|
@ -59,14 +59,26 @@ impl BufferLogger {
|
||||||
f(self.buffer.borrow_mut().extract())
|
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) {
|
pub fn set_max_log_level(&self, max_level: LogLevelFilter) {
|
||||||
self.filter
|
self.filter
|
||||||
.borrow()
|
.borrow()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("register the logger before setting maximum log level")
|
.expect("register the logger before touching maximum log level")
|
||||||
.set(max_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) {
|
pub fn set_uart_log_level(&self, max_level: LogLevelFilter) {
|
||||||
self.uart_filter.set(max_level)
|
self.uart_filter.set(max_level)
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ pub extern fn main() -> i32 {
|
||||||
panic!("out of memory");
|
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);
|
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
use logger_artiq::BufferLogger;
|
use logger_artiq::BufferLogger;
|
||||||
|
use log::LogLevelFilter;
|
||||||
use sched::Io;
|
use sched::Io;
|
||||||
use sched::{TcpListener, TcpStream};
|
use sched::{TcpListener, TcpStream};
|
||||||
use board;
|
use board;
|
||||||
|
@ -25,9 +26,13 @@ fn worker(mut stream: &mut TcpStream) -> io::Result<()> {
|
||||||
match Request::read_from(stream)? {
|
match Request::read_from(stream)? {
|
||||||
Request::GetLog => {
|
Request::GetLog => {
|
||||||
BufferLogger::with_instance(|logger| {
|
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)
|
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) {
|
pub fn thread(io: Io) {
|
||||||
let listener = TcpListener::new(&io, 65535);
|
let listener = TcpListener::new(&io, 8192);
|
||||||
listener.listen(1380).expect("mgmt: cannot listen");
|
listener.listen(1380).expect("mgmt: cannot listen");
|
||||||
info!("management interface active");
|
info!("management interface active");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue