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

Consistent usage of dimming vs bold in #2408

Closed
howardjohn opened this issue Dec 8, 2022 · 1 comment · Fixed by #2409
Closed

Consistent usage of dimming vs bold in #2408

howardjohn opened this issue Dec 8, 2022 · 1 comment · Fixed by #2409

Comments

@howardjohn
Copy link
Contributor

Feature Request

Crates

tracing-subscriber

Motivation

Consistency between format modes and improved format. AKA bikeshedding.

Proposal

With the default format, target is dimmed. This looks great and makes it easy to distinguish the real log from the target.

The Compact format, IMO, is a bit nicer in general though. However, it doesn't dim the target. I didn't see any obvious reason these were different; the motivation to dim in the default format was to make it easier to distinguish the components of the log, which still applies in Compact.

To be more concrete, I suggest a change like:

diff --git a/tracing-subscriber/src/fmt/format/mod.rs b/tracing-subscriber/src/fmt/format/mod.rs
index ed0a697..2574597 100644
--- a/tracing-subscriber/src/fmt/format/mod.rs
+++ b/tracing-subscriber/src/fmt/format/mod.rs
@@ -1068,12 +1068,12 @@ where
         let bold = writer.bold();
         let dimmed = writer.dimmed();
         if self.display_target {
-            write!(writer, "{}{}", bold.paint(meta.target()), dimmed.paint(":"))?;
+            write!(writer, "{}{}", dimmed.paint(meta.target()), dimmed.paint(":"))?;
         }

         if self.display_filename {
             if let Some(filename) = meta.file() {
-                write!(writer, "{}{}", bold.paint(filename), dimmed.paint(":"))?;
+                write!(writer, "{}{}", dimmed.paint(filename), dimmed.paint(":"))?;
             }
         }

@@ -1082,9 +1082,9 @@ where
                 write!(
                     writer,
                     "{}{}{}{}",
-                    bold.prefix(),
+                    dimmed.prefix(),
                     line_number,
-                    bold.suffix(),
+                    dimmed.suffix(),
                     dimmed.paint(":")
                 )?;
             }

Alternatives

Users could implement their own format, but its a lot of code copying for a fairly small change. Or not use Compact.

@hawkw
Copy link
Member

hawkw commented Dec 8, 2022

I would happily merge a PR which makes the Compact and Full formats more consistent. Thank you!

howardjohn added a commit to howardjohn/tracing that referenced this issue Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants