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

enabled built-in go error formatting instead of requriring tintErr wrapping, colorized debug level text to increase readability #67

Closed
wants to merge 5 commits into from

Conversation

pwntr
Copy link

@pwntr pwntr commented Jul 10, 2024

Thank you this nice package, since moving to slog I was missing the pretty zerolog-like output. Until I discovered tint :)!

PR summary:

  • bugfix/feature [45f85b4]: without resorting to the package provided tintErr error type wrapper, users using the native slog API to log errors didn't get colorized/red output for error messages.
    By asserting the built-in error interface directly, both the tintErr and any other errors (satisfying the error interface) get the colorization treatment, also regardless of the key provided for the error value.
    This kinda makes the whole tintError type obsolete (and I would recommend removing it altogether eventually), but I left it in for backwards compatibility in case users of this package called tint.Err(err) in their business logic or own package wrappers. Using the native slog API is certainly more portable, as one doesn't need to provide a wrapper package for slog and/or tint in that case.

    Preview:
    Screenshot_20240710_175030

  • feature [3fbd1c2]: added faint magenta as a foreground color for debug messages, to visually isolate the DBG level text better from the log message text that follows -> increases readability when glancing over output and increases 🌈 level

    Preview:
    Screenshot_20240710_175712

@lmittmann
Copy link
Owner

I appreciate the effort, but will not merge this PR.

bugfix/feature [https://github.com/lmittmann/tint/commit/45f85b4332dd6db4f3428d8b6dd319edde5bd961]

I consider it a feature to be able to only log some errors in color. Since #66 you can change the tint.Err key value, if needed.

feature [https://github.com/lmittmann/tint/commit/3fbd1c23bc3bd4c79d4c68e630b88a09dc777416]

If you want to customize the level color you can use the ReplaceAttr-option. Although I admit, this is not very pleasant. However, a better API to customize the level color without hurting performance has not been proposed yet.

@lmittmann lmittmann closed this Jul 10, 2024
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.

2 participants