Ir al contenido

Error Not Logged With Object (ARCH5159)

Esta página aún no está disponible en tu idioma.

Key go.logging.error-not-logged · Severity warning · Category logging

Logging an error with only a constant message while dropping the error value itself discards the root-cause chain and any wrapped context. The error object should always be attached as a log field.

func sync(log *slog.Logger) {
if err := pull(); err != nil {
log.Error("sync failed")
}
}
func sync(log *slog.Logger) {
if err := pull(); err != nil {
log.Error("sync failed", "err", err)
}
}

Attach the error as a field ("err", err) on the log call to preserve the root cause.