log: using maps.Clone (#29392)

pull/29451/head
cui 6 months ago committed by GitHub
parent 6b39e9236c
commit eea0acc549
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      log/handler_glog.go

@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"regexp"
"runtime"
"strconv"
@ -145,10 +146,7 @@ func (h *GlogHandler) Enabled(ctx context.Context, lvl slog.Level) bool {
func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
h.lock.RLock()
siteCache := make(map[uintptr]slog.Level)
for k, v := range h.siteCache {
siteCache[k] = v
}
siteCache := maps.Clone(h.siteCache)
h.lock.RUnlock()
patterns := []pattern{}

Loading…
Cancel
Save