feat: make OpaqueError FanctTrace more legible
This commit is contained in:
parent
0e2afd0772
commit
5dc61a0f12
1 changed files with 6 additions and 4 deletions
|
|
@ -61,9 +61,10 @@ impl OpaqueError {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
let str = vec.iter().rfold(String::new(), |mut acc, x| {
|
let str = vec.iter().rfold(String::new(), |mut acc, x| {
|
||||||
let first = acc.len() != 0;
|
let first = acc.len() == 0;
|
||||||
if first {
|
if !first {
|
||||||
acc.push_str(":");
|
// TODO: should this code be hardcoded?
|
||||||
|
acc.push_str("\x1b[2m:\x1b[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.push_str(x.0);
|
acc.push_str(x.0);
|
||||||
|
|
@ -74,6 +75,7 @@ impl OpaqueError {
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
});
|
});
|
||||||
|
|
||||||
FancyTrace { str }
|
FancyTrace { str }
|
||||||
}
|
}
|
||||||
pub fn set_level(mut self, lvl: Level) -> Self {
|
pub fn set_level(mut self, lvl: Level) -> Self {
|
||||||
|
|
@ -92,7 +94,7 @@ pub struct FancyTrace {
|
||||||
}
|
}
|
||||||
impl fmt::Display for FancyTrace {
|
impl fmt::Display for FancyTrace {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.str)
|
write!(f, "\x1b[2m{{{{\x1b[0m {} \x1b[2m}}}}\x1b[0m", self.str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue