github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/internal/mocks/logging/tracer.go (about)

     1  //go:build !gomock && !generate
     2  
     3  package mocklogging
     4  
     5  import (
     6  	"net"
     7  
     8  	"github.com/apernet/quic-go/internal/mocks/logging/internal"
     9  	"github.com/apernet/quic-go/logging"
    10  
    11  	"go.uber.org/mock/gomock"
    12  )
    13  
    14  type MockTracer = internal.MockTracer
    15  
    16  func NewMockTracer(ctrl *gomock.Controller) (*logging.Tracer, *MockTracer) {
    17  	t := internal.NewMockTracer(ctrl)
    18  	return &logging.Tracer{
    19  		SentPacket: func(remote net.Addr, hdr *logging.Header, size logging.ByteCount, frames []logging.Frame) {
    20  			t.SentPacket(remote, hdr, size, frames)
    21  		},
    22  		SentVersionNegotiationPacket: func(remote net.Addr, dest, src logging.ArbitraryLenConnectionID, versions []logging.VersionNumber) {
    23  			t.SentVersionNegotiationPacket(remote, dest, src, versions)
    24  		},
    25  		DroppedPacket: func(remote net.Addr, typ logging.PacketType, size logging.ByteCount, reason logging.PacketDropReason) {
    26  			t.DroppedPacket(remote, typ, size, reason)
    27  		},
    28  		Debug: func(name, msg string) {
    29  			t.Debug(name, msg)
    30  		},
    31  		Close: func() {
    32  			t.Close()
    33  		},
    34  	}, t
    35  }