From 9c920bc893f27e4225da9188bdaf1f826110e01e Mon Sep 17 00:00:00 2001 From: DarthSim Date: Tue, 19 Jul 2022 18:04:54 +0600 Subject: [PATCH] Ser ErrorLog for server --- server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.go b/server.go index ee660106..7161d3ff 100644 --- a/server.go +++ b/server.go @@ -4,6 +4,7 @@ import ( "context" "crypto/subtle" "fmt" + golog "log" "net/http" "time" @@ -50,10 +51,16 @@ func startServer(cancel context.CancelFunc) (*http.Server, error) { l = netutil.LimitListener(l, config.MaxClients) } + errLogger := golog.New( + log.WithField("source", "http_server").WriterLevel(log.ErrorLevel), + "", 0, + ) + s := &http.Server{ Handler: buildRouter(), ReadTimeout: time.Duration(config.ReadTimeout) * time.Second, MaxHeaderBytes: 1 << 20, + ErrorLog: errLogger, } if config.KeepAliveTimeout > 0 {