mirror of https://github.com/m-labs/artiq.git
frimware: update to log 0.4.
This commit is contained in:
parent
745e695b09
commit
b7f38b123b
|
@ -41,7 +41,7 @@ dependencies = [
|
||||||
"board 0.0.0",
|
"board 0.0.0",
|
||||||
"build_artiq 0.0.0",
|
"build_artiq 0.0.0",
|
||||||
"build_misoc 0.0.0",
|
"build_misoc 0.0.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -81,6 +81,11 @@ name = "cc"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compiler_builtins"
|
name = "compiler_builtins"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -107,7 +112,7 @@ dependencies = [
|
||||||
"build_misoc 0.0.0",
|
"build_misoc 0.0.0",
|
||||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"std_artiq 0.0.0",
|
"std_artiq 0.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -157,6 +162,14 @@ name = "log"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log_buffer"
|
name = "log_buffer"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -167,7 +180,7 @@ name = "logger_artiq"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"board 0.0.0",
|
"board 0.0.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -183,7 +196,7 @@ dependencies = [
|
||||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dyld 0.0.0",
|
"dyld 0.0.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"std_artiq 0.0.0",
|
"std_artiq 0.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -202,7 +215,7 @@ dependencies = [
|
||||||
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"drtioaux 0.0.0",
|
"drtioaux 0.0.0",
|
||||||
"fringe 1.1.0 (git+https://github.com/m-labs/libfringe?rev=bd23494)",
|
"fringe 1.1.0 (git+https://github.com/m-labs/libfringe?rev=bd23494)",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"logger_artiq 0.0.0",
|
"logger_artiq 0.0.0",
|
||||||
"proto 0.0.0",
|
"proto 0.0.0",
|
||||||
"smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=507d2fe)",
|
"smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=507d2fe)",
|
||||||
|
@ -228,7 +241,7 @@ dependencies = [
|
||||||
"build_artiq 0.0.0",
|
"build_artiq 0.0.0",
|
||||||
"build_misoc 0.0.0",
|
"build_misoc 0.0.0",
|
||||||
"drtioaux 0.0.0",
|
"drtioaux 0.0.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"logger_artiq 0.0.0",
|
"logger_artiq 0.0.0",
|
||||||
"std_artiq 0.0.0",
|
"std_artiq 0.0.0",
|
||||||
]
|
]
|
||||||
|
@ -272,6 +285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum build_const 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e90dc84f5e62d2ebe7676b83c22d33b6db8bd27340fb6ffbff0a364efa0cb9c9"
|
"checksum build_const 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e90dc84f5e62d2ebe7676b83c22d33b6db8bd27340fb6ffbff0a364efa0cb9c9"
|
||||||
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
||||||
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
|
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
|
||||||
|
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||||
"checksum compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=1c765ad)" = "<none>"
|
"checksum compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=1c765ad)" = "<none>"
|
||||||
"checksum crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5d02c0aac6bd68393ed69e00bbc2457f3e89075c6349db7189618dc4ddc1d7"
|
"checksum crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5d02c0aac6bd68393ed69e00bbc2457f3e89075c6349db7189618dc4ddc1d7"
|
||||||
"checksum cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f8cb7306107e4b10e64994de6d3274bd08996a7c1322a27b86482392f96be0a"
|
"checksum cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f8cb7306107e4b10e64994de6d3274bd08996a7c1322a27b86482392f96be0a"
|
||||||
|
@ -279,6 +293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||||
"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
|
"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
|
||||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||||
|
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
|
||||||
"checksum log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec57723b84bbe7bdf76aa93169c9b59e67473317c6de3a83cb2a0f8ccb2aa493"
|
"checksum log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec57723b84bbe7bdf76aa93169c9b59e67473317c6de3a83cb2a0f8ccb2aa493"
|
||||||
"checksum managed 0.4.0 (git+https://github.com/m-labs/rust-managed.git?rev=629a6786a1cf1692015f464ed16c04eafa5cb8d1)" = "<none>"
|
"checksum managed 0.4.0 (git+https://github.com/m-labs/rust-managed.git?rev=629a6786a1cf1692015f464ed16c04eafa5cb8d1)" = "<none>"
|
||||||
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
||||||
|
|
|
@ -14,7 +14,7 @@ build_artiq = { path = "../libbuild_artiq" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
log = { version = "0.3", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
board = { path = "../libboard" }
|
board = { path = "../libboard" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -12,7 +12,7 @@ path = "lib.rs"
|
||||||
build_misoc = { path = "../libbuild_misoc" }
|
build_misoc = { path = "../libbuild_misoc" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = { version = "0.3", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
crc = { version = "1.7", default-features = false }
|
crc = { version = "1.7", default-features = false }
|
||||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||||
board = { path = "../libboard" }
|
board = { path = "../libboard" }
|
||||||
|
|
|
@ -8,6 +8,6 @@ name = "logger_artiq"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = { version = "0.3", default-features = false, features = [] }
|
log = { version = "0.4", default-features = false }
|
||||||
log_buffer = { version = "1.0" }
|
log_buffer = { version = "1.0" }
|
||||||
board = { path = "../libboard" }
|
board = { path = "../libboard" }
|
||||||
|
|
|
@ -7,14 +7,13 @@ extern crate board;
|
||||||
|
|
||||||
use core::cell::{Cell, RefCell};
|
use core::cell::{Cell, RefCell};
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use log::{Log, LogMetadata, LogRecord, LogLevelFilter, MaxLogLevelFilter};
|
use log::{Log, LevelFilter};
|
||||||
use log_buffer::LogBuffer;
|
use log_buffer::LogBuffer;
|
||||||
use board::clock;
|
use board::clock;
|
||||||
|
|
||||||
pub struct BufferLogger {
|
pub struct BufferLogger {
|
||||||
buffer: RefCell<LogBuffer<&'static mut [u8]>>,
|
buffer: RefCell<LogBuffer<&'static mut [u8]>>,
|
||||||
filter: RefCell<Option<MaxLogLevelFilter>>,
|
uart_filter: Cell<LevelFilter>
|
||||||
uart_filter: Cell<LogLevelFilter>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut LOGGER: *const BufferLogger = 0 as *const _;
|
static mut LOGGER: *const BufferLogger = 0 as *const _;
|
||||||
|
@ -23,28 +22,18 @@ impl BufferLogger {
|
||||||
pub fn new(buffer: &'static mut [u8]) -> BufferLogger {
|
pub fn new(buffer: &'static mut [u8]) -> BufferLogger {
|
||||||
BufferLogger {
|
BufferLogger {
|
||||||
buffer: RefCell::new(LogBuffer::new(buffer)),
|
buffer: RefCell::new(LogBuffer::new(buffer)),
|
||||||
filter: RefCell::new(None),
|
uart_filter: Cell::new(LevelFilter::Info),
|
||||||
uart_filter: Cell::new(LogLevelFilter::Info),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register<F: FnOnce()>(&self, f: F) {
|
pub fn register<F: FnOnce()>(&self, f: F) {
|
||||||
// log::set_logger_raw captures a pointer to ourselves, so we must prevent
|
|
||||||
// ourselves from being moved or dropped after that function is called (and
|
|
||||||
// before log::shutdown_logger_raw is called).
|
|
||||||
unsafe {
|
unsafe {
|
||||||
log::set_logger_raw(|max_log_level| {
|
|
||||||
max_log_level.set(LogLevelFilter::Info);
|
|
||||||
*self.filter.borrow_mut() = Some(max_log_level);
|
|
||||||
self as *const Log
|
|
||||||
}).expect("global logger can only be initialized once");
|
|
||||||
LOGGER = self;
|
LOGGER = self;
|
||||||
|
log::set_logger(&*LOGGER)
|
||||||
|
.expect("global logger can only be initialized once");
|
||||||
}
|
}
|
||||||
|
log::set_max_level(LevelFilter::Info);
|
||||||
f();
|
f();
|
||||||
log::shutdown_logger_raw().unwrap();
|
|
||||||
unsafe {
|
|
||||||
LOGGER = 0 as *const _;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with<R, F: FnOnce(&BufferLogger) -> R>(f: F) -> R {
|
pub fn with<R, F: FnOnce(&BufferLogger) -> R>(f: F) -> R {
|
||||||
|
@ -60,34 +49,18 @@ impl BufferLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract<R, F: FnOnce(&str) -> R>(&self, f: F) -> R {
|
pub fn extract<R, F: FnOnce(&str) -> R>(&self, f: F) -> R {
|
||||||
let old_log_level = self.max_log_level();
|
let old_log_level = log::max_level();
|
||||||
self.set_max_log_level(LogLevelFilter::Off);
|
log::set_max_level(LevelFilter::Off);
|
||||||
let result = f(self.buffer.borrow_mut().extract());
|
let result = f(self.buffer.borrow_mut().extract());
|
||||||
self.set_max_log_level(old_log_level);
|
log::set_max_level(old_log_level);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_log_level(&self) -> LogLevelFilter {
|
pub fn uart_log_level(&self) -> LevelFilter {
|
||||||
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 touching maximum log level")
|
|
||||||
.set(max_level)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn uart_log_level(&self) -> LogLevelFilter {
|
|
||||||
self.uart_filter.get()
|
self.uart_filter.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_uart_log_level(&self, max_level: LogLevelFilter) {
|
pub fn set_uart_log_level(&self, max_level: LevelFilter) {
|
||||||
self.uart_filter.set(max_level)
|
self.uart_filter.set(max_level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,11 +69,11 @@ impl BufferLogger {
|
||||||
unsafe impl Sync for BufferLogger {}
|
unsafe impl Sync for BufferLogger {}
|
||||||
|
|
||||||
impl Log for BufferLogger {
|
impl Log for BufferLogger {
|
||||||
fn enabled(&self, _metadata: &LogMetadata) -> bool {
|
fn enabled(&self, _metadata: &log::Metadata) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(&self, record: &LogRecord) {
|
fn log(&self, record: &log::Record) {
|
||||||
if self.enabled(record.metadata()) {
|
if self.enabled(record.metadata()) {
|
||||||
let timestamp = clock::get_us();
|
let timestamp = clock::get_us();
|
||||||
let seconds = timestamp / 1_000_000;
|
let seconds = timestamp / 1_000_000;
|
||||||
|
@ -116,4 +89,7 @@ impl Log for BufferLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(&self) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,6 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = { version = "1.0", default-features = false }
|
byteorder = { version = "1.0", default-features = false }
|
||||||
cslice = { version = "0.3" }
|
cslice = { version = "0.3" }
|
||||||
log = { version = "0.3", default-features = false, optional = true }
|
log = { version = "0.4", default-features = false, optional = true }
|
||||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||||
dyld = { path = "../libdyld" }
|
dyld = { path = "../libdyld" }
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::vec::Vec;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use {ReadExt, WriteExt};
|
use {ReadExt, WriteExt};
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
use log::LogLevelFilter;
|
use log;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Request {
|
pub enum Request {
|
||||||
|
@ -10,9 +10,9 @@ pub enum Request {
|
||||||
ClearLog,
|
ClearLog,
|
||||||
PullLog,
|
PullLog,
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
SetLogFilter(LogLevelFilter),
|
SetLogFilter(log::LevelFilter),
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
SetUartLogFilter(LogLevelFilter),
|
SetUartLogFilter(log::LevelFilter),
|
||||||
|
|
||||||
Hotswap(Vec<u8>),
|
Hotswap(Vec<u8>),
|
||||||
Reboot,
|
Reboot,
|
||||||
|
@ -29,14 +29,14 @@ pub enum Reply<'a> {
|
||||||
impl Request {
|
impl Request {
|
||||||
pub fn read_from(reader: &mut Read) -> io::Result<Request> {
|
pub fn read_from(reader: &mut Read) -> io::Result<Request> {
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
fn read_log_level_filter(reader: &mut Read) -> io::Result<LogLevelFilter> {
|
fn read_log_level_filter(reader: &mut Read) -> io::Result<log::LevelFilter> {
|
||||||
Ok(match reader.read_u8()? {
|
Ok(match reader.read_u8()? {
|
||||||
0 => LogLevelFilter::Off,
|
0 => log::LevelFilter::Off,
|
||||||
1 => LogLevelFilter::Error,
|
1 => log::LevelFilter::Error,
|
||||||
2 => LogLevelFilter::Warn,
|
2 => log::LevelFilter::Warn,
|
||||||
3 => LogLevelFilter::Info,
|
3 => log::LevelFilter::Info,
|
||||||
4 => LogLevelFilter::Debug,
|
4 => log::LevelFilter::Debug,
|
||||||
5 => LogLevelFilter::Trace,
|
5 => log::LevelFilter::Trace,
|
||||||
_ => return Err(io::Error::new(io::ErrorKind::InvalidData,
|
_ => return Err(io::Error::new(io::ErrorKind::InvalidData,
|
||||||
"invalid log level"))
|
"invalid log level"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,7 @@ build_artiq = { path = "../libbuild_artiq" }
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = { version = "1.0", default-features = false }
|
byteorder = { version = "1.0", default-features = false }
|
||||||
cslice = { version = "0.3" }
|
cslice = { version = "0.3" }
|
||||||
log = { version = "0.3", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
board = { path = "../libboard", features = ["uart_console", "smoltcp"] }
|
board = { path = "../libboard", features = ["uart_console", "smoltcp"] }
|
||||||
alloc_list = { path = "../liballoc_list" }
|
alloc_list = { path = "../liballoc_list" }
|
||||||
std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] }
|
std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] }
|
||||||
|
|
|
@ -164,8 +164,7 @@ fn startup_ethernet() {
|
||||||
Ok(Ok(log_level_filter)) => {
|
Ok(Ok(log_level_filter)) => {
|
||||||
info!("log level set to {} by `log_level` config key",
|
info!("log level set to {} by `log_level` config key",
|
||||||
log_level_filter);
|
log_level_filter);
|
||||||
logger_artiq::BufferLogger::with(|logger|
|
log::set_max_level(log_level_filter);
|
||||||
logger.set_max_log_level(log_level_filter));
|
|
||||||
}
|
}
|
||||||
_ => info!("log level set to INFO by default")
|
_ => info!("log level set to INFO by default")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use board::boot;
|
use board::boot;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use log::LogLevelFilter;
|
use log::{self, LevelFilter};
|
||||||
use logger_artiq::BufferLogger;
|
use logger_artiq::BufferLogger;
|
||||||
use sched::Io;
|
use sched::Io;
|
||||||
use sched::{TcpListener, TcpStream};
|
use sched::{TcpListener, TcpStream};
|
||||||
|
@ -44,11 +44,11 @@ fn worker(io: &Io, stream: &mut TcpStream) -> io::Result<()> {
|
||||||
io.until(|| BufferLogger::with(|logger| !logger.is_empty()))?;
|
io.until(|| BufferLogger::with(|logger| !logger.is_empty()))?;
|
||||||
|
|
||||||
BufferLogger::with(|logger| {
|
BufferLogger::with(|logger| {
|
||||||
let log_level = logger.max_log_level();
|
let log_level = log::max_level();
|
||||||
logger.extract(|log| {
|
logger.extract(|log| {
|
||||||
stream.write_string(log)?;
|
stream.write_string(log)?;
|
||||||
|
|
||||||
if log_level == LogLevelFilter::Trace {
|
if log_level == LevelFilter::Trace {
|
||||||
// Hold exclusive access over the logger until we get positive
|
// Hold exclusive access over the logger until we get positive
|
||||||
// acknowledgement; otherwise we get an infinite loop of network
|
// acknowledgement; otherwise we get an infinite loop of network
|
||||||
// trace messages being transmitted and causing more network
|
// trace messages being transmitted and causing more network
|
||||||
|
@ -69,8 +69,7 @@ fn worker(io: &Io, stream: &mut TcpStream) -> io::Result<()> {
|
||||||
|
|
||||||
Request::SetLogFilter(level) => {
|
Request::SetLogFilter(level) => {
|
||||||
info!("changing log level to {}", level);
|
info!("changing log level to {}", level);
|
||||||
BufferLogger::with(|logger|
|
log::set_max_level(level);
|
||||||
logger.set_max_log_level(level));
|
|
||||||
Reply::Success.write_to(stream)?;
|
Reply::Success.write_to(stream)?;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ build_misoc = { path = "../libbuild_misoc" }
|
||||||
build_artiq = { path = "../libbuild_artiq" }
|
build_artiq = { path = "../libbuild_artiq" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = { version = "0.3", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
alloc_list = { path = "../liballoc_list" }
|
alloc_list = { path = "../liballoc_list" }
|
||||||
board = { path = "../libboard", features = ["uart_console"] }
|
board = { path = "../libboard", features = ["uart_console"] }
|
||||||
board_artiq = { path = "../libboard_artiq" }
|
board_artiq = { path = "../libboard_artiq" }
|
||||||
|
|
Loading…
Reference in New Issue