Skip to content

Commit 17e889a

Browse files
authored
feat: improve logging for reconnectingPTY connections
part of #7963 improves connection logging on reconnectingPTY
1 parent b402f2a commit 17e889a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

agent/agent.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,10 @@ func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *t
833833
}
834834
break
835835
}
836-
logger.Debug(ctx, "accepted conn", slog.F("remote", conn.RemoteAddr().String()))
836+
clog := logger.With(
837+
slog.F("remote", conn.RemoteAddr().String()),
838+
slog.F("local", conn.LocalAddr().String()))
839+
clog.Info(ctx, "accepted conn")
837840
wg.Add(1)
838841
closed := make(chan struct{})
839842
go func() {
@@ -865,7 +868,7 @@ func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *t
865868
logger.Warn(ctx, "failed to unmarshal init", slog.F("raw", data))
866869
return
867870
}
868-
_ = a.handleReconnectingPTY(ctx, logger, msg, conn)
871+
_ = a.handleReconnectingPTY(ctx, clog, msg, conn)
869872
}()
870873
}
871874
wg.Wait()
@@ -1021,12 +1024,12 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10211024
// If the agent is closed, we don't want to
10221025
// log this as an error since it's expected.
10231026
if closed {
1024-
connLogger.Debug(ctx, "reconnecting pty failed with attach error (agent closed)", slog.Error(err))
1027+
connLogger.Info(ctx, "reconnecting pty failed with attach error (agent closed)", slog.Error(err))
10251028
} else {
10261029
connLogger.Error(ctx, "reconnecting pty failed with attach error", slog.Error(err))
10271030
}
10281031
}
1029-
connLogger.Debug(ctx, "reconnecting pty connection closed")
1032+
connLogger.Info(ctx, "reconnecting pty connection closed")
10301033
}()
10311034

10321035
var rpty reconnectingpty.ReconnectingPTY

0 commit comments

Comments
 (0)