From 819440f839b32c88c58e6b5ec58077bd8d40506c Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 18 Jul 2017 02:53:55 +0000 Subject: [PATCH] runtime: split log timestamp into secs.micros. --- artiq/firmware/liblogger_artiq/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/artiq/firmware/liblogger_artiq/lib.rs b/artiq/firmware/liblogger_artiq/lib.rs index fbaae4f47..b4ca62993 100644 --- a/artiq/firmware/liblogger_artiq/lib.rs +++ b/artiq/firmware/liblogger_artiq/lib.rs @@ -94,10 +94,14 @@ impl Log for BufferLogger { fn log(&self, record: &LogRecord) { if self.enabled(record.metadata()) { + let timestamp = clock::get_us(); + let seconds = timestamp / 1_000_000; + let micros = timestamp % 1_000_000; + let force_uart = match self.buffer.try_borrow_mut() { Ok(mut buffer) => { - writeln!(buffer, "[{:12}us] {:>5}({}): {}", - clock::get_us(), record.level(), + writeln!(buffer, "[{:6}.{:06}s] {:>5}({}): {}", + seconds, micros, record.level(), record.target(), record.args()).unwrap(); false } @@ -109,8 +113,8 @@ impl Log for BufferLogger { }; if record.level() <= self.uart_filter.get() || force_uart { - writeln!(Console, "[{:12}us] {:>5}({}): {}", - clock::get_us(), record.level(), + writeln!(Console, "[{:6}.{:06}s] {:>5}({}): {}", + seconds, micros, record.level(), record.target(), record.args()).unwrap(); } }