Ir al contenido

Print Instead Of Logger (ARCH5157)

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

Key go.logging.fmt-print-instead-of-logger · Severity warning · Category logging

Writing directly to stdout/stderr with fmt.Println or fmt.Printf bypasses the structured logger that provides levels, structure, and sink routing. Diagnostic output should go through the framework logger.

func handle(req *Request) {
fmt.Println("processing request", req.ID)
// ...
}
func handle(req *Request, log *slog.Logger) {
log.Info("processing request", "id", req.ID)
// ...
}

Use a structured logger (log/slog) instead of fmt.Print*.