lets-go:10.2 structured server logging

This commit is contained in:
tamsin johnson 2024-02-07 09:19:49 -08:00
parent bf9dcd1247
commit 9c353ced51

View File

@ -67,8 +67,16 @@ func main() {
sessionManager: sessionManager,
}
logger.Info("starting server", slog.String("addr", *addr))
err = http.ListenAndServe(*addr, app.routes())
srv := &http.Server{
Addr: *addr,
Handler: app.routes(),
ErrorLog: slog.NewLogLogger(logger.Handler(), slog.LevelError),
}
logger.Info("starting server", slog.String("addr", srv.Addr))
err = srv.ListenAndServe()
logger.Error(err.Error())
os.Exit(1)
}