Skip to content

Modern Docker Management, Designed for Everyone

fix: remove full stack trace from logging

Kyle Mendell1bed0714fc36
diff --git a/backend/internal/bootstrap/logger_bootstrap.go b/backend/internal/bootstrap/logger_bootstrap.go
index da188e45b..33d0e3cf1 100644
--- a/backend/internal/bootstrap/logger_bootstrap.go
+++ b/backend/internal/bootstrap/logger_bootstrap.go
@@ -161,6 +161,15 @@ func normalizeRequestLogErrorInternal(a slog.Attr) slog.Attr {
return a
}
+func replaceErrorAttrInternal(_ []string, a slog.Attr) slog.Attr {
+ if a.Value.Kind() == slog.KindAny {
+ if err, ok := a.Value.Any().(error); ok {
+ return slog.String(a.Key, err.Error())
+ }
+ }
+ return a
+}
+
func (h *requestLogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
return &requestLogHandler{handler: h.handler.WithAttrs(attrs)}
}
@@ -215,11 +224,15 @@ func SetupSlogLogger(cfg *config.Config) {
var h slog.Handler
if cfg.LogJson {
- h = slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: lv})
+ h = slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
+ Level: lv,
+ ReplaceAttr: replaceErrorAttrInternal,
+ })
} else {
h = tint.NewTextHandler(os.Stdout, &tint.Options{
- Level: lv,
- TimeFormat: "Jan 02 15:04:05.000",
+ Level: lv,
+ TimeFormat: "Jan 02 15:04:05.000",
+ ReplaceAttr: replaceErrorAttrInternal,
})
}