forked from quic-go/quic-go
logging: add a Debug function to the Tracer (#4297)
This commit is contained in:
@@ -64,6 +64,12 @@ var _ = Describe("Tracing", func() {
|
||||
tr2.EXPECT().DroppedPacket(remote, PacketTypeRetry, ByteCount(1024), PacketDropDuplicate)
|
||||
tracer.DroppedPacket(remote, PacketTypeRetry, 1024, PacketDropDuplicate)
|
||||
})
|
||||
|
||||
It("traces the Debug event", func() {
|
||||
tr1.EXPECT().Debug("foo", "bar")
|
||||
tr2.EXPECT().Debug("foo", "bar")
|
||||
tracer.Debug("foo", "bar")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ type Tracer struct {
|
||||
SentPacket func(net.Addr, *Header, ByteCount, []Frame)
|
||||
SentVersionNegotiationPacket func(_ net.Addr, dest, src ArbitraryLenConnectionID, _ []VersionNumber)
|
||||
DroppedPacket func(net.Addr, PacketType, ByteCount, PacketDropReason)
|
||||
Debug func(name, msg string)
|
||||
}
|
||||
|
||||
// NewMultiplexedTracer creates a new tracer that multiplexes events to multiple tracers.
|
||||
@@ -39,5 +40,12 @@ func NewMultiplexedTracer(tracers ...*Tracer) *Tracer {
|
||||
}
|
||||
}
|
||||
},
|
||||
Debug: func(name, msg string) {
|
||||
for _, t := range tracers {
|
||||
if t.Debug != nil {
|
||||
t.Debug(name, msg)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user