-
Notifications
You must be signed in to change notification settings - Fork 77
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
integrate Slog into logx #327
base: main
Are you sure you want to change the base?
Conversation
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.
5 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings
logx/slogx/slog.go
Outdated
func toSlogFields(fields ...logx.LogField) []interface{} { | ||
slogFields := make([]interface{}, 0, len(fields) * 2) | ||
for _, field := range fields { | ||
slogFields = append(slogFields, field.Key, field.Value) | ||
} | ||
|
||
return slogFields | ||
} |
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.
style: toSlogFields creates a new slice for each call. Consider using a pool for better performance in high-volume logging scenarios.
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.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
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.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
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
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
#325
Greptile Summary
This pull request integrates the new log/slog package from Go 1.21 into the logx module of the zero-contrib project, implementing a SlogWriter struct in logx/slogx/slog.go to adapt the logx.Writer interface for slog usage.
logx/slogx/slog.go
for consistent formatting across all types in log messagestoSlogFields
function to create a single slice for all fields, improving efficiencySlogWriter
struct with methods for various log levels (Debug, Error, Info, etc.) using slogNewSlogWriter
function to create a newlogx.Writer
instance using slog.Handler