Skip to content

Commit ee30c97

Browse files
committed
Add info logs for starting, stopping, and attaching
In the case of screen, attach also starts so there is no separate start log there.
1 parent c7978db commit ee30c97

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

agent/reconnectingpty/buffered.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,17 @@ func (rpty *bufferedReconnectingPTY) lifecycle(ctx context.Context, logger slog.
168168
logger.Debug(ctx, "killed process with error", slog.Error(err))
169169
}
170170

171-
logger.Debug(ctx, "closed reconnecting pty")
171+
logger.Info(ctx, "closed reconnecting pty")
172172
rpty.state.setState(StateDone, xerrors.Errorf("reconnecting pty closed: %w", reasonErr))
173173
}
174174

175175
func (rpty *bufferedReconnectingPTY) Attach(ctx context.Context, connID string, conn net.Conn, height, width uint16, logger slog.Logger) error {
176+
logger.Info(ctx, "attach to reconnecting pty")
177+
176178
// This will kill the heartbeat once we hit EOF or an error.
177179
ctx, cancel := context.WithCancel(ctx)
178180
defer cancel()
179181

180-
logger.Debug(ctx, "reconnecting pty attach")
181182
err := rpty.doAttach(ctx, connID, conn, height, width, logger)
182183
if err != nil {
183184
return err

agent/reconnectingpty/reconnectingpty.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func New(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog.Logger
7676
}
7777
logger.Debug(ctx, "auto backend selection", slog.F("backend", options.BackendType))
7878
}
79+
80+
logger.Info(ctx, "start reconnecting pty")
81+
7982
switch options.BackendType {
8083
case codersdk.ReconnectingPTYBackendTypeScreen:
8184
return newScreen(ctx, cmd, options, logger)

agent/reconnectingpty/screen.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,17 @@ func (rpty *screenReconnectingPTY) lifecycle(ctx context.Context, logger slog.Lo
144144
logger.Error(ctx, "close screen session", slog.Error(err))
145145
}
146146

147-
logger.Debug(ctx, "closed reconnecting pty")
147+
logger.Info(ctx, "closed reconnecting pty")
148148
rpty.state.setState(StateDone, xerrors.Errorf("reconnecting pty closed: %w", reasonErr))
149149
}
150150

151151
func (rpty *screenReconnectingPTY) Attach(ctx context.Context, _ string, conn net.Conn, height, width uint16, logger slog.Logger) error {
152+
logger.Info(ctx, "attach to reconnecting pty")
153+
152154
// This will kill the heartbeat once we hit EOF or an error.
153155
ctx, cancel := context.WithCancel(ctx)
154156
defer cancel()
155157

156-
logger.Debug(ctx, "reconnecting pty attach")
157158
ptty, process, err := rpty.doAttach(ctx, height, width, logger)
158159
if err != nil {
159160
return err

0 commit comments

Comments
 (0)