mirror of
https://github.com/jsiebens/ionscale.git
synced 2026-03-31 15:07:49 +01:00
chore: http errorlog to zap
This commit is contained in:
@@ -9,10 +9,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func handler(h http.Handler) echo.HandlerFunc {
|
||||
return echo.WrapHandler(h)
|
||||
}
|
||||
|
||||
func EchoErrorHandler() echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
|
||||
@@ -193,11 +193,11 @@ func Start(ctx context.Context, c *config.Config) error {
|
||||
http2Server := &http2.Server{}
|
||||
g := new(errgroup.Group)
|
||||
|
||||
g.Go(func() error { return http.Serve(httpL, h2c.NewHandler(tlsAppHandler, http2Server)) })
|
||||
g.Go(func() error { return http.Serve(metricsL, metricsHandler) })
|
||||
g.Go(func() error { return httpServe(httpLogger, httpL, h2c.NewHandler(tlsAppHandler, http2Server)) })
|
||||
g.Go(func() error { return httpServe(httpLogger, metricsL, metricsHandler) })
|
||||
|
||||
if tlsL != nil {
|
||||
g.Go(func() error { return http.Serve(nonTlsL, nonTlsAppHandler) })
|
||||
g.Go(func() error { return httpServe(httpLogger, nonTlsL, nonTlsAppHandler) })
|
||||
}
|
||||
|
||||
if c.Tls.AcmeEnabled {
|
||||
@@ -277,6 +277,20 @@ func selectListener(a net.Listener, b net.Listener) net.Listener {
|
||||
return b
|
||||
}
|
||||
|
||||
func httpServe(logger *zap.Logger, l net.Listener, handler http.Handler) error {
|
||||
errorLog, err := zap.NewStdLogAt(logger, zap.DebugLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s := &http.Server{
|
||||
Handler: handler,
|
||||
ErrorLog: errorLog,
|
||||
}
|
||||
|
||||
return s.Serve(l)
|
||||
}
|
||||
|
||||
func setupLogging(config config.Logging) (*zap.Logger, error) {
|
||||
level, err := zap.ParseAtomicLevel(config.Level)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user