From 48779d053f2ab3c0361a4e685ce7f429cac8f280 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 22 Aug 2022 13:14:50 +0300 Subject: [PATCH] add a logging.NullTracer --- codecov.yml | 2 +- ...ll_connection_tracer.go => null_tracer.go} | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) rename logging/{null_connection_tracer.go => null_tracer.go} (79%) diff --git a/codecov.yml b/codecov.yml index 0d453d44..074d9832 100644 --- a/codecov.yml +++ b/codecov.yml @@ -12,7 +12,7 @@ coverage: - internal/utils/newconnectionid_linkedlist.go - internal/utils/packetinterval_linkedlist.go - internal/utils/linkedlist/linkedlist.go - - logging/null_connection_tracer.go + - logging/null_tracer.go - fuzzing/ - metrics/ status: diff --git a/logging/null_connection_tracer.go b/logging/null_tracer.go similarity index 79% rename from logging/null_connection_tracer.go rename to logging/null_tracer.go index 3fe04c73..ff789f79 100644 --- a/logging/null_connection_tracer.go +++ b/logging/null_tracer.go @@ -1,18 +1,30 @@ package logging import ( + "context" "net" "time" ) -// The NullConnectionTracer is a ConnectionTracer that does nothing. -// It is useful for embedding. Don't modify this variable! -var NullConnectionTracer ConnectionTracer = &nullConnectionTracer{} +var ( + // The NullTracer is a Tracer that does nothing. + // 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{} -var _ ConnectionTracer = &nullConnectionTracer{} - func (n nullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) { }