Explorar el Código

fix: slog error log serialization (#1276)

Aiden Cline hace 8 meses
padre
commit
a16554d445
Se han modificado 1 ficheros con 12 adiciones y 2 borrados
  1. 12 2
      packages/tui/internal/util/apilogger.go

+ 12 - 2
packages/tui/internal/util/apilogger.go

@@ -66,12 +66,22 @@ func (h *APILogHandler) Handle(ctx context.Context, r slog.Record) error {
 
 	h.mu.Lock()
 	for _, attr := range h.attrs {
-		extra[attr.Key] = attr.Value.Any()
+		val := attr.Value.Any()
+		if err, ok := val.(error); ok {
+			extra[attr.Key] = err.Error()
+		} else {
+			extra[attr.Key] = val
+		}
 	}
 	h.mu.Unlock()
 
 	r.Attrs(func(attr slog.Attr) bool {
-		extra[attr.Key] = attr.Value.Any()
+		val := attr.Value.Any()
+		if err, ok := val.(error); ok {
+			extra[attr.Key] = err.Error()
+		} else {
+			extra[attr.Key] = val
+		}
 		return true
 	})