From bbe565df9f069d405eedd978f3bd8566d6daabfb Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 25 Jul 2024 11:03:45 -0700 Subject: [PATCH] fix: log attrs being dropped (#2168) - Fixes #2167 --- internal/log/logger.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/log/logger.go b/internal/log/logger.go index 93994fa80..99aaf4cc6 100644 --- a/internal/log/logger.go +++ b/internal/log/logger.go @@ -74,7 +74,13 @@ func (l *Logger) Log(entry Entry) { if entry.Time.IsZero() { entry.Time = time.Now() } - entry.Attributes = l.attributes + + // merge logger and entry attributes + mergedAttributes := make(map[string]string) + maps.Copy(mergedAttributes, l.attributes) + maps.Copy(mergedAttributes, entry.Attributes) + entry.Attributes = mergedAttributes + if err := l.sink.Log(entry); err != nil { fmt.Fprintf(os.Stderr, "ftl:log: failed to log entry: %v", err) }