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 support for Themes #2

Merged
merged 2 commits into from
Nov 21, 2023
Merged

Add support for Themes #2

merged 2 commits into from
Nov 21, 2023

Conversation

injeniero
Copy link
Contributor

@injeniero injeniero commented Nov 10, 2023

While working with it, I found the color scheme you used was making it really hard to read long messages because they would have the same color for the Timestamp and AttrValue. So I thought it would be great to make it configurable.

Other changes in this PR:

  • Use HandlerOptions in encoder to avoid repeating code.
  • HandlerOptions should not be a pointer as it can't be modified from the outside. This is the same implementation as in slog.Handler.
  • Encoder doesn't have internal state, so no need to be a pointer.
  • Default Theme tries to follow as close as possible Zerolog's Console theme.
  • Do not print empty Attr as described in Handler.Handle: This is described in Handler.Handle method: If an Attr's key and value are both the zero value, ignore the Attr.

- Use HandlerOptions in encoder to avoid repeating code
- HandlerOptions should not be a pointer as it can't be modified from the outside
- Encoder doesn't have internal state, so no need to be a pointer
- Default Theme tries to follow as close as possible Zerolog's Console theme
@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

This is described in Handler.Handle method: If an Attr's key and value are both the zero value, ignore the Attr.
@injeniero
Copy link
Contributor Author

@phsym do you have an ETA for when you can review this?

@phsym
Copy link
Owner

phsym commented Nov 17, 2023

Hi @injeniero I reviewed it already and it looks good to me. I just want to give it a try before merging. Give me a few days as I'm a bit busy on other stuff

@phsym phsym self-requested a review November 21, 2023 09:20
@phsym
Copy link
Owner

phsym commented Nov 21, 2023

@injeniero Thanks a lot. Works like a charm

@phsym phsym merged commit bdde01c into phsym:main Nov 21, 2023
1 check passed
@phsym
Copy link
Owner

phsym commented Nov 21, 2023

Released in v0.3.0

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 this pull request may close these issues.

3 participants