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

Add a custom log formatter class #118

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Conversation

Pennycook
Copy link
Contributor

Makes the following two changes to the log format:

  • Use lower-case prefixes to mimic compiler behavior.
  • Use ASCII color codes when available.

Related issues

Closes #25.

Proposed changes

  • Add a new Formatter class that applies the desired formatting to our logs.
  • Disable colors when writing to file, because ASCII codes don't work there.
  • Disable colors when stdout is redirected to a file.

We might want to revisit this much later on if we want to be really fancy (i.e., if we want to do things like allow warning messages to highlight different parts of their own messages, etc) but the difference from just providing a little bit of color is pretty striking:

image

- Use lower-case prefixes to mimic compiler behavior.
- Use ASCII color codes when available.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook added the enhancement New feature or request label Sep 26, 2024
@Pennycook Pennycook added this to the 2.0.0 milestone Sep 26, 2024
Copy link
Contributor

@laserkelvin laserkelvin left a comment

Choose a reason for hiding this comment

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

Potentially out of scope for this PR since messages aren't defined here, but reading the example I think it would be good to either bold or allocate a new color to differentiate between user/system libraries, i.e. make "user" and "system" stick out more.

@Pennycook
Copy link
Contributor Author

Potentially out of scope for this PR since messages aren't defined here, but reading the example I think it would be good to either bold or allocate a new color to differentiate between user/system libraries, i.e. make "user" and "system" stick out more.

Yeah, I agree it would be nice to do this.

It's going to require more work, though, as we'll need to come up with a way to filter out any ASCII codes that might appear as part of a message. We'd probably want to come up with (or adopt) some standardized representation of colors and things for the messages. Right now we don't have to worry about that, because the only place these special codes can appear is inside of the logger implementation.

We should open an issue to track it.

@Pennycook Pennycook merged commit 65c4392 into intel:main Oct 9, 2024
3 checks passed
@Pennycook Pennycook deleted the log-format branch October 9, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logging format could be improved
2 participants