Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to fix the color on location info #2063

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions probe-rs/src/bin/probe-rs/util/rtt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::*;
use anyhow::{anyhow, Result};
use colored::Colorize;
use defmt_decoder::DecodeError;
use num_traits::Zero;
pub use probe_rs::rtt::ChannelMode;
Expand Down Expand Up @@ -464,9 +465,20 @@ impl RttActiveTarget {
// 3. Default with timestamp without location
// 4. Default without timestamp with location
// 5. Default without timestamp without location
let mut fileinfo = String::new();
let format = log_format.unwrap_or(match (show_location, has_timestamp) {
(true, true) => "{t} {L} {s}\n└─ {m} @ {F}:{l}",
(true, false) => "{L} {s}\n└─ {m} @ {F}:{l}",
(true, true) => {
fileinfo.push_str("{t} {L} {s}\n");
fileinfo.push_str(&"└─ {m} @ {F}:{l}".dimmed());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this won't work because the color information somehow gets lost when you go from ColoredString to String. I don't remember the details.

What you're trying to do should be supported by the defmt log formatter with this format string:

Suggested change
fileinfo.push_str(&"└─ {m} @ {F}:{l}".dimmed());
fileinfo.push_str(&"{└─ {m} @ {F}:{l}%dimmed}");

But the current version of defmt does not support this yet, we need a new release.


&fileinfo
}
(true, false) => {
fileinfo.push_str("{L} {s}\n");
fileinfo.push_str(&"└─ {m} @ {F}:{l}".dimmed());

&fileinfo
}
(false, true) => "{t} {L} {s}",
(false, false) => "{L} {s}",
});
Expand Down
Loading