From afa20b220d5dd275a12063da306b4db0ec257e5e Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Mon, 11 May 2026 09:05:49 +0000 Subject: [PATCH] Include errors in logging This fixes #850 by ensuring that error types are converted into JSON-serializable strings. I can't think of other types than error where we'd log something that isn't a string/int primitive, but if needed, more can be added here. --- internal/logger/gcp.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/logger/gcp.go b/internal/logger/gcp.go index 7c2fb112..b98cb1c7 100644 --- a/internal/logger/gcp.go +++ b/internal/logger/gcp.go @@ -184,7 +184,13 @@ func (h *Exporter) Handle(ctx context.Context, r slog.Record) error { // in the entry. case slog.LevelKey, slog.TimeKey: default: - target[a.Key] = a.Value.Any() + v := a.Value.Any() + // Map types to something JSON serialisable. + if err, ok := v.(error); ok { + target[a.Key] = err.Error() + } else { + target[a.Key] = v + } } return true })