From e6e761b391c58bce54aaa57928ad1764c6aeeda7 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 27 Sep 2024 13:59:55 -0400 Subject: [PATCH 1/2] feat(websocket): switch the underlying http server logger to use ipfs/go-log --- p2p/transport/websocket/listener.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/p2p/transport/websocket/listener.go b/p2p/transport/websocket/listener.go index 3ff72830d1..8071ddb814 100644 --- a/p2p/transport/websocket/listener.go +++ b/p2p/transport/websocket/listener.go @@ -4,16 +4,22 @@ import ( "crypto/tls" "errors" "fmt" + "go.uber.org/zap" "net" "net/http" "sync" + logging "github.com/ipfs/go-log/v2" + "github.com/libp2p/go-libp2p/core/transport" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" ) +var log = logging.Logger("websocket-transport") +var stdLog = zap.NewStdLog(log.Desugar()) + type listener struct { nl net.Listener server http.Server @@ -82,7 +88,7 @@ func newListener(a ma.Multiaddr, tlsConf *tls.Config) (*listener, error) { incoming: make(chan *Conn), closed: make(chan struct{}), } - ln.server = http.Server{Handler: ln} + ln.server = http.Server{Handler: ln, ErrorLog: stdLog} if parsed.isWSS { ln.isWss = true ln.server.TLSConfig = tlsConf From 7e1d57d9a130ebc00fcd2e7b0b87d1f0d08537dc Mon Sep 17 00:00:00 2001 From: sukun Date: Mon, 30 Sep 2024 15:17:12 +0530 Subject: [PATCH 2/2] gocheck fixes --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 684f354427..ec6d7346c7 100644 --- a/go.mod +++ b/go.mod @@ -60,6 +60,7 @@ require ( go.uber.org/fx v1.22.1 go.uber.org/goleak v1.3.0 go.uber.org/mock v0.4.0 + go.uber.org/zap v1.27.0 golang.org/x/crypto v0.25.0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/sync v0.7.0 @@ -123,7 +124,6 @@ require ( github.com/wlynxg/anet v0.0.3 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/text v0.16.0 // indirect