aboutsummaryrefslogtreecommitdiff
path: root/internal/log/stackdriverlogger/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/log/stackdriverlogger/log.go')
-rw-r--r--internal/log/stackdriverlogger/log.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/internal/log/stackdriverlogger/log.go b/internal/log/stackdriverlogger/log.go
index 0238070f..5de8653d 100644
--- a/internal/log/stackdriverlogger/log.go
+++ b/internal/log/stackdriverlogger/log.go
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
stdlog "log"
+ "maps"
"os"
"strings"
"sync"
@@ -41,9 +42,7 @@ func NewContextWithLabel(ctx context.Context, key, value string) context.Context
oldLabels, _ := ctx.Value(labelsKey{}).(map[string]string)
// Copy the labels, to preserve immutability of contexts.
newLabels := map[string]string{}
- for k, v := range oldLabels {
- newLabels[k] = v
- }
+ maps.Copy(newLabels, oldLabels)
newLabels[key] = value
return context.WithValue(ctx, labelsKey{}, newLabels)
}
@@ -86,9 +85,7 @@ func (l *logger) Log(ctx context.Context, s log.Severity, payload any) {
es := experimentString(ctx)
if len(es) > 0 {
nl := map[string]string{}
- for k, v := range labels {
- nl[k] = v
- }
+ maps.Copy(nl, labels)
nl["experiments"] = es
labels = nl
}