add a logging.NullTracer

This commit is contained in:
Marten Seemann 2022-08-22 13:14:50 +03:00
parent 118a7dba5a
commit 48779d053f
2 changed files with 18 additions and 6 deletions

View file

@ -12,7 +12,7 @@ coverage:
- internal/utils/newconnectionid_linkedlist.go - internal/utils/newconnectionid_linkedlist.go
- internal/utils/packetinterval_linkedlist.go - internal/utils/packetinterval_linkedlist.go
- internal/utils/linkedlist/linkedlist.go - internal/utils/linkedlist/linkedlist.go
- logging/null_connection_tracer.go - logging/null_tracer.go
- fuzzing/ - fuzzing/
- metrics/ - metrics/
status: status:

View file

@ -1,18 +1,30 @@
package logging package logging
import ( import (
"context"
"net" "net"
"time" "time"
) )
// The NullConnectionTracer is a ConnectionTracer that does nothing. var (
// It is useful for embedding. Don't modify this variable! // The NullTracer is a Tracer that does nothing.
var NullConnectionTracer ConnectionTracer = &nullConnectionTracer{} // It is useful for embedding. Don't modify this variable!
NullTracer Tracer = &nullTracer{}
// The NullConnectionTracer is a ConnectionTracer that does nothing.
// It is useful for embedding. Don't modify this variable!
NullConnectionTracer ConnectionTracer = &nullConnectionTracer{}
)
type nullTracer struct{}
func (n nullTracer) TracerForConnection(context.Context, Perspective, ConnectionID) ConnectionTracer {
return NullConnectionTracer
}
func (n nullTracer) SentPacket(net.Addr, *Header, ByteCount, []Frame) {}
func (n nullTracer) DroppedPacket(net.Addr, PacketType, ByteCount, PacketDropReason) {}
type nullConnectionTracer struct{} type nullConnectionTracer struct{}
var _ ConnectionTracer = &nullConnectionTracer{}
func (n nullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) { func (n nullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) {
} }