From b8ba5b444c06f373714ecef20492976f5fdc18f6 Mon Sep 17 00:00:00 2001 From: Nuno Diegues Date: Mon, 30 May 2022 13:42:56 +0100 Subject: [PATCH] TUN-6301: Allow to update logger used by UDP session manager --- datagramsession/manager.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/datagramsession/manager.go b/datagramsession/manager.go index a691e3f9..54c5c24d 100644 --- a/datagramsession/manager.go +++ b/datagramsession/manager.go @@ -29,6 +29,8 @@ type Manager interface { RegisterSession(ctx context.Context, sessionID uuid.UUID, dstConn io.ReadWriteCloser) (*Session, error) // UnregisterSession stops tracking the session and terminates it UnregisterSession(ctx context.Context, sessionID uuid.UUID, message string, byRemote bool) error + // UpdateLogger updates the logger used by the Manager + UpdateLogger(log *zerolog.Logger) } type manager struct { @@ -57,6 +59,11 @@ func NewManager(transport transport, log *zerolog.Logger) *manager { } } +func (m *manager) UpdateLogger(log *zerolog.Logger) { + // Benign data race, no problem if the old pointer is read or not concurrently. + m.log = log +} + func (m *manager) Serve(ctx context.Context) error { errGroup, ctx := errgroup.WithContext(ctx) errGroup.Go(func() error {