|
1 | 1 | use std::io::Write;
|
2 | 2 |
|
3 |
| -use crossterm::{ |
4 |
| - style::{Color, Print, PrintStyledContent, Stylize}, |
5 |
| - QueueableCommand, |
6 |
| -}; |
| 3 | +use crossterm::{style::Print, QueueableCommand}; |
7 | 4 | use defmt_decoder::{Frame, Table};
|
8 | 5 | use miette::{bail, Context, Diagnostic, Result};
|
9 | 6 | use thiserror::Error;
|
@@ -140,31 +137,8 @@ impl EspDefmt {
|
140 | 137 | }
|
141 | 138 |
|
142 | 139 | 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(); |
168 | 142 |
|
169 | 143 | out.flush().unwrap();
|
170 | 144 | }
|
|
0 commit comments