Skip to content

Commit

Permalink
Remove empty check from WithAttrs and WithGroup
Browse files Browse the repository at this point in the history
These are checked by slog.Logger
  • Loading branch information
MrAlias committed Mar 11, 2024
1 parent 277c0f4 commit 01f7612
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions bridges/sloghandler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ func (h *Handler) Enabled(context.Context, slog.Level) bool {
// WithAttrs returns a new [slog.Handler] based on h that will log using the
// passed attrs.
func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler {
if len(attrs) == 0 {
return h
}

h2 := *h
if h2.group != nil {
h2.group.AddAttrs(attrs)
Expand All @@ -125,11 +121,6 @@ func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler {
// WithGroup returns a new [slog.Handler] based on h that will log all messages
// and attributes within a group using name.
func (h *Handler) WithGroup(name string) slog.Handler {
// Handlers should inline the Attrs of a group with an empty key.
if name == "" {
return h
}

h2 := *h
h2.group = &group{name: name, next: h2.group}
return &h2
Expand Down

0 comments on commit 01f7612

Please sign in to comment.