-
Notifications
You must be signed in to change notification settings - Fork 291
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: added slog adapter #1173
feat: added slog adapter #1173
Conversation
977a979
to
d6930ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple comments on the details, but thank you for this PR! I think this addition makes sense. Since slog is in the standard library, I think this can be generally used by anybody who wants to. cc: @tchung1118, if you think this is good too we can merge and include in the next Fx release.
fdf7380
to
48825e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few more comments. I think it looks good otherwise. Thank you again for your contribution.
fxevent/slog.go
Outdated
"strings" | ||
) | ||
|
||
var _ Logger = &SlogLogger{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
var _ Logger = &SlogLogger{} | |
var _ Logger = (*SlogLogger)(nil) |
fxevent/slog.go
Outdated
|
||
var _ Logger = &SlogLogger{} | ||
|
||
// SlogLogger is a shim that allows uber/fx to use slog for logging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
// SlogLogger is a shim that allows uber/fx to use slog for logging. | |
// SlogLogger is an Fx event logger that logs events using a slog logger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
fxevent/slog.go
Outdated
} | ||
|
||
func slogStrings(key string, str []string) slog.Attr { | ||
var attrs []any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pre-allocate here?
var attrs []any | |
attrs := make([]slog.Attr, 0, len(str)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! resolved
ea83500
to
4ba319f
Compare
0d94756
to
9475fc1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1173 +/- ##
==========================================
+ Coverage 98.71% 98.73% +0.02%
==========================================
Files 30 31 +1
Lines 2648 2851 +203
==========================================
+ Hits 2614 2815 +201
- Misses 27 29 +2
Partials 7 7 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Unsure if this is even wanted however, this PR introduces an adapter (originally from here) to more easily use slog as the underlying logger implementation instead of zap.
This covers: #1170