lets-go:10.2 structured server logging
This commit is contained in:
parent
bf9dcd1247
commit
9c353ced51
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user