mirror of https://github.com/m-labs/artiq.git
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 {
|
pub fn get_ms() -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::timer0::update_value_write(1);
|
csr::timer0::update_value_write(1);
|
||||||
|
|
|
@ -2,6 +2,7 @@ use core::{mem, ptr};
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use log::{self, Log, LogMetadata, LogRecord, LogLevelFilter};
|
use log::{self, Log, LogMetadata, LogRecord, LogLevelFilter};
|
||||||
use log_buffer::LogBuffer;
|
use log_buffer::LogBuffer;
|
||||||
|
use clock;
|
||||||
|
|
||||||
pub struct BufferLogger {
|
pub struct BufferLogger {
|
||||||
buffer: RefCell<LogBuffer<&'static mut [u8]>>
|
buffer: RefCell<LogBuffer<&'static mut [u8]>>
|
||||||
|
@ -57,10 +58,11 @@ impl Log for BufferLogger {
|
||||||
fn log(&self, record: &LogRecord) {
|
fn log(&self, record: &LogRecord) {
|
||||||
if self.enabled(record.metadata()) {
|
if self.enabled(record.metadata()) {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
writeln!(self.buffer.borrow_mut(), "{:>5}({}): {}",
|
writeln!(self.buffer.borrow_mut(),
|
||||||
record.level(), record.target(), record.args()).unwrap();
|
"[{:12}us] {:>5}({}): {}",
|
||||||
println!("{:>5}({}): {}",
|
clock::get_us(), record.level(), record.target(), record.args()).unwrap();
|
||||||
record.level(), record.target(), record.args());
|
println!("[{:12}us] {:>5}({}): {}",
|
||||||
|
clock::get_us(), record.level(), record.target(), record.args());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue