Skip to content

Commit

Permalink
slog: Don't log if not enabled at level
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored Feb 5, 2024
1 parent f2cb6b6 commit 049bd2c
Showing 1 changed file with 4 additions and 0 deletions.
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 @@ func (l *Logger) Enabled(_ context.Context, level slog.Level) bool {
//
// Implements slog.Handler.
func (l *Logger) Handle(_ context.Context, record slog.Record) error {
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

0 comments on commit 049bd2c

Please sign in to comment.