Skip to content

Commit

Permalink
feat(websocket): switch the underlying http server logger to use ipfs…
Browse files Browse the repository at this point in the history
…/go-log (#2985)
  • Loading branch information
aschmahmann authored Sep 30, 2024
1 parent 9038a72 commit 005f9b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion p2p/transport/websocket/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 005f9b6

Please sign in to comment.