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

slog: Don't log if not enabled at level #103

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions logger_121.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
//
// Implements slog.Handler.
func (l *Logger) Handle(_ context.Context, record slog.Record) error {
aymanbagabas marked this conversation as resolved.
Show resolved Hide resolved
if !l.Enabled(ctx, record.Level) {

Check failure on line 25 in logger_121.go

View workflow job for this annotation

GitHub Actions / coverage / coverage

undefined: ctx

Check failure on line 25 in logger_121.go

View workflow job for this annotation

GitHub Actions / build (stable) / build (ubuntu-latest)

undefined: ctx

Check failure on line 25 in logger_121.go

View workflow job for this annotation

GitHub Actions / build (stable) / govulncheck

undefined: ctx
return nil
}

fields := make([]interface{}, 0, record.NumAttrs()*2)
record.Attrs(func(a slog.Attr) bool {
fields = append(fields, a.Key, a.Value.String())
Expand Down
Loading