From 1853c5f32587485fe31c9705cc6877c038e62702 Mon Sep 17 00:00:00 2001 From: Pierre-Henri Symoneaux Date: Wed, 16 Aug 2023 21:24:06 +0200 Subject: [PATCH] trim spaces in group names --- zerolog.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zerolog.go b/zerolog.go index c2b54ea..3807b2c 100644 --- a/zerolog.go +++ b/zerolog.go @@ -9,6 +9,7 @@ import ( "log/slog" "net" "runtime" + "strings" "time" "github.com/rs/zerolog" @@ -58,8 +59,9 @@ func NewHandler(logger zerolog.Logger, opts *HandlerOptions) *Handler { if opts == nil { opts = new(HandlerOptions) } + opt := *opts // Copy return &Handler{ - opts: opts, + opts: &opt, logger: logger, } } @@ -138,7 +140,7 @@ func (h *Handler) WithGroup(name string) slog.Handler { return &groupHandler{ parent: h, ctx: zerolog.Context{}, - name: name, + name: strings.TrimSpace(name), } }