forked from M-Labs/artiq
runtime: print microsecond timestamps in debug messages.
This commit is contained in:
parent
dca3fb5c96
commit
acc5e53b32
@ -12,6 +12,13 @@ pub fn init() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_us() -> u64 {
|
||||
unsafe {
|
||||
csr::timer0::update_value_write(1);
|
||||
(INIT - csr::timer0::value_read()) / (FREQ / 1_000_000)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ms() -> u64 {
|
||||
unsafe {
|
||||
csr::timer0::update_value_write(1);
|
||||
|
@ -2,6 +2,7 @@ use core::{mem, ptr};
|
||||
use core::cell::RefCell;
|
||||
use log::{self, Log, LogMetadata, LogRecord, LogLevelFilter};
|
||||
use log_buffer::LogBuffer;
|
||||
use clock;
|
||||
|
||||
pub struct BufferLogger {
|
||||
buffer: RefCell<LogBuffer<&'static mut [u8]>>
|
||||
@ -57,10 +58,11 @@ impl Log for BufferLogger {
|
||||
fn log(&self, record: &LogRecord) {
|
||||
if self.enabled(record.metadata()) {
|
||||
use core::fmt::Write;
|
||||
writeln!(self.buffer.borrow_mut(), "{:>5}({}): {}",
|
||||
record.level(), record.target(), record.args()).unwrap();
|
||||
println!("{:>5}({}): {}",
|
||||
record.level(), record.target(), record.args());
|
||||
writeln!(self.buffer.borrow_mut(),
|
||||
"[{:12}us] {:>5}({}): {}",
|
||||
clock::get_us(), record.level(), record.target(), record.args()).unwrap();
|
||||
println!("[{:12}us] {:>5}({}): {}",
|
||||
clock::get_us(), record.level(), record.target(), record.args());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user