From d8f0e0ea6e357c2b47d5883e0d68d4d0f3904ec1 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Mon, 12 Aug 2024 08:55:28 -0700 Subject: [PATCH] Simplify error logging on event send (#20246) Overly verbose, hard to read and can leak data. Print even as JSON and simplify target&error printing. --- internal/logger/logger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 27365fd9f..432629bf2 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -20,6 +20,7 @@ package logger import ( "context" "encoding/hex" + "encoding/json" "errors" "fmt" "go/build" @@ -421,7 +422,8 @@ func sendLog(ctx context.Context, entry log.Entry) { for _, t := range systemTgts { if err := t.Send(ctx, entry); err != nil { if consoleTgt != nil { // Sending to the console never fails - entry.Trace.Message = fmt.Sprintf("event(%#v) was not sent to Logger target (%#v): %#v", entry, t, err) + b, _ := json.Marshal(entry) + entry.Trace.Message = fmt.Sprintf("sendLog: event %s was not sent to Logger target (%v): %v", string(b), t.String(), err.Error()) consoleTgt.Send(ctx, entry) } }