logging: add a Close function to the Tracer (#4298)

* logging: add a Close function to the Tracer

* close the Tracer when the Transport is closed
This commit is contained in:
Marten Seemann
2024-02-03 12:12:15 +07:00
committed by GitHub
parent b675e34254
commit 07ec3245bd
8 changed files with 65 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ type Tracer struct {
SentVersionNegotiationPacket func(_ net.Addr, dest, src ArbitraryLenConnectionID, _ []VersionNumber)
DroppedPacket func(net.Addr, PacketType, ByteCount, PacketDropReason)
Debug func(name, msg string)
Close func()
}
// NewMultiplexedTracer creates a new tracer that multiplexes events to multiple tracers.
@@ -47,5 +48,12 @@ func NewMultiplexedTracer(tracers ...*Tracer) *Tracer {
}
}
},
Close: func() {
for _, t := range tracers {
if t.Close != nil {
t.Close()
}
}
},
}
}