Browse Source

quic: move the qlog tracer to a separate package

pull/1828/head
Marten Seemann 2 years ago
parent
commit
81f9f10fc8
  1. 4
      p2p/transport/quic/transport.go
  2. 12
      p2p/transport/quicutils/tracer.go
  3. 2
      p2p/transport/quicutils/tracer_test.go

4
p2p/transport/quic/transport.go

@ -10,6 +10,8 @@ import (
"sync"
"time"
"github.com/libp2p/go-libp2p/p2p/transport/quicutils"
"golang.org/x/crypto/hkdf"
"github.com/libp2p/go-libp2p/core/connmgr"
@ -201,7 +203,7 @@ func NewTransport(key ic.PrivKey, psk pnet.PSK, gater connmgr.ConnectionGater, r
return nil, err
}
var tracers []quiclogging.Tracer
if qlogTracer != nil {
if qlogTracer := quicutils.QLOGTracer; qlogTracer != nil {
tracers = append(tracers, qlogTracer)
}
if cfg.metrics {

12
p2p/transport/quic/tracer.go → p2p/transport/quicutils/tracer.go

@ -1,4 +1,4 @@
package libp2pquic
package quicutils
import (
"bufio"
@ -7,17 +7,21 @@ import (
"os"
"time"
golog "github.com/ipfs/go-log/v2"
"github.com/klauspost/compress/zstd"
"github.com/lucas-clemente/quic-go/logging"
"github.com/lucas-clemente/quic-go/qlog"
)
var qlogTracer logging.Tracer
var log = golog.Logger("quic-utils")
// QLOGTracer holds a qlog tracer, if qlogging is enabled (enabled using the QLOGDIR environment variable).
// Otherwise it is nil.
var QLOGTracer logging.Tracer
func init() {
if qlogDir := os.Getenv("QLOGDIR"); len(qlogDir) > 0 {
qlogTracer = initQlogger(qlogDir)
QLOGTracer = initQlogger(qlogDir)
}
}

2
p2p/transport/quic/tracer_test.go → p2p/transport/quicutils/tracer_test.go

@ -1,4 +1,4 @@
package libp2pquic
package quicutils
import (
"bytes"
Loading…
Cancel
Save