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

feat: implement -context-only #14

Merged
merged 4 commits into from
Oct 22, 2023
Merged

Conversation

mattdowdell
Copy link
Collaborator

@mattdowdell mattdowdell commented Oct 21, 2023

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
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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 Coverage Δ
sloglint.go 90.44% <100.00%> (+0.44%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tmzane tmzane changed the title Add -context-only option feat: implement -context-only Oct 21, 2023
@tmzane
Copy link
Member

tmzane commented Oct 21, 2023

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

sloglint.go Outdated Show resolved Hide resolved
As described in go-simpler#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.Context`.
sloglint.go Outdated Show resolved Hide resolved
@tmzane tmzane merged commit 1301dc6 into go-simpler:main Oct 22, 2023
7 checks passed
@tmzane
Copy link
Member

tmzane commented Oct 22, 2023

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

@mattdowdell mattdowdell deleted the matt/context-only branch October 23, 2023 06:47
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