Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(websocket): switch the underlying http server logger to use ipfs/go-log #2985

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading