go-simpler / sloglint

🪵 Ensure consistent code style when using log/slog
https://go-simpler.org/sloglint
Mozilla Public License 2.0
75 stars 5 forks source link

feat: implement `-context-only` #14

Closed mattdowdell closed 8 months ago

mattdowdell commented 8 months ago

As described in #13, third-party implementations of slog.Handler can choose to take values out of a context to supplement the attributes already used. An example of this in my day job is adding trace IDs to enhance serviceability.

This change adds the ability to optionally identify slog methods that do not take a context and so prevent the ability to take values from that context. Any matches can be resolved by appending Context to the method. For example, slog.Info becomes slog.InfoContext.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (bc45156) 90.00% compared to head (2735b70) 90.44%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #14 +/- ## ========================================== + Coverage 90.00% 90.44% +0.44% ========================================== Files 1 1 Lines 130 136 +6 ========================================== + Hits 117 123 +6 Misses 9 9 Partials 4 4 ``` | [Files](https://app.codecov.io/gh/go-simpler/sloglint/pull/14?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-simpler) | Coverage Δ | | |---|---|---| | [sloglint.go](https://app.codecov.io/gh/go-simpler/sloglint/pull/14?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-simpler#diff-c2xvZ2xpbnQuZ28=) | `90.44% <100.00%> (+0.44%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tmzane commented 8 months ago

Looks great! I appreciate you added the documentation as well :)

tmzane commented 8 months ago

@mattdowdell I've updated the report message and rearranged the options slightly. Thank you for the contribution!