subscriber: dim Compact targets, matching the default formatter (#2409)

## Motivation

Fixes https://github.com/tokio-rs/tracing/issues/2408

## Solution

Just switch to use `dim`

Before:
![2022-12-08_13-58-40](https://user-images.githubusercontent.com/623453/206576169-63ee4e20-b56f-4c63-a9b3-80ba2e97eec9.png)
After:
![2022-12-08_13-55-36](https://user-images.githubusercontent.com/623453/206576055-878d360f-7b95-4e18-bc31-4fb6f1b71a3a.png)
Full mode for comparison:
![2022-12-08_13-55-48](https://user-images.githubusercontent.com/623453/206576054-6e38852c-cb3a-4b84-98e5-50463cdb5073.png)
This commit is contained in:
John Howard 2022-12-08 14:25:27 -08:00 committed by Eliza Weisman
parent 6c55b66915
commit 10c32f23b3

View File

@ -1082,12 +1082,11 @@ where
};
write!(writer, "{}", fmt_ctx)?;
let bold = writer.bold();
let dimmed = writer.dimmed();
let mut needs_space = false;
if self.display_target {
write!(writer, "{}{}", bold.paint(meta.target()), dimmed.paint(":"))?;
write!(writer, "{}{}", dimmed.paint(meta.target()), dimmed.paint(":"))?;
needs_space = true;
}
@ -1096,7 +1095,7 @@ where
if self.display_target {
writer.write_char(' ')?;
}
write!(writer, "{}{}", bold.paint(filename), dimmed.paint(":"))?;
write!(writer, "{}{}", dimmed.paint(filename), dimmed.paint(":"))?;
needs_space = true;
}
}
@ -1106,9 +1105,9 @@ where
write!(
writer,
"{}{}{}{}",
bold.prefix(),
dimmed.prefix(),
line_number,
bold.suffix(),
dimmed.suffix(),
dimmed.paint(":")
)?;
needs_space = true;
@ -2039,7 +2038,7 @@ pub(super) mod test {
#[cfg(feature = "ansi")]
#[test]
fn with_ansi_true() {
let expected = "\u{1b}[2mfake time\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[1mtracing_subscriber::fmt::format::test\u{1b}[0m\u{1b}[2m:\u{1b}[0m hello\n";
let expected = "\u{1b}[2mfake time\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[2mtracing_subscriber::fmt::format::test\u{1b}[0m\u{1b}[2m:\u{1b}[0m hello\n";
test_ansi(true, expected, crate::fmt::Subscriber::builder().compact())
}