Skip to content

Commit 30300c4

Browse files
Display timestamp, useful to find timing problem (#680)
Co-authored-by: Jesse Braham <[email protected]>
1 parent c119e61 commit 30300c4

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Add new chip detect magic value, ability to read chip revision for ESP32-P4 (#686)
1313

1414
### Fixed
15+
1516
- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)
17+
- espflash defmt log didn't display timestamp, according to [defmt doc](https://defmt.ferrous-systems.com/timestamps). (#680)
1618

1719
### Changed
1820

espflash/src/cli/monitor/parser/esp_defmt.rs

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use std::io::Write;
22

3-
use crossterm::{
4-
style::{Color, Print, PrintStyledContent, Stylize},
5-
QueueableCommand,
6-
};
3+
use crossterm::{style::Print, QueueableCommand};
74
use defmt_decoder::{Frame, Table};
85
use miette::{bail, Context, Diagnostic, Result};
96
use thiserror::Error;
@@ -140,31 +137,8 @@ impl EspDefmt {
140137
}
141138

142139
fn handle_defmt(frame: Frame<'_>, out: &mut dyn Write) {
143-
match frame.level() {
144-
Some(level) => {
145-
let color = match level {
146-
defmt_parser::Level::Trace => Color::Cyan,
147-
defmt_parser::Level::Debug => Color::Blue,
148-
defmt_parser::Level::Info => Color::Green,
149-
defmt_parser::Level::Warn => Color::Yellow,
150-
defmt_parser::Level::Error => Color::Red,
151-
};
152-
153-
// Print the level before each line.
154-
let level = level.as_str().to_uppercase();
155-
for line in frame.display_message().to_string().lines() {
156-
out.queue(PrintStyledContent(
157-
format!("[{level}] - {line}\r\n").with(color),
158-
))
159-
.unwrap();
160-
}
161-
}
162-
None => {
163-
out.queue(Print(frame.display_message().to_string()))
164-
.unwrap();
165-
out.queue(Print("\r\n")).unwrap();
166-
}
167-
}
140+
out.queue(Print(frame.display(true).to_string())).unwrap();
141+
out.queue(Print("\r\n")).unwrap();
168142

169143
out.flush().unwrap();
170144
}

0 commit comments

Comments
 (0)