Skip to content

Commit b279f1a

Browse files
committed
Agent logging in appstest
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 504c0cf commit b279f1a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

agent/agent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
648648
}
649649
break
650650
}
651+
logger.Debug(ctx, "accepted pty conn", slog.F("remote", conn.RemoteAddr().String()))
651652
wg.Add(1)
652653
closed := make(chan struct{})
653654
go func() {
@@ -676,6 +677,7 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
676677
var msg codersdk.WorkspaceAgentReconnectingPTYInit
677678
err = json.Unmarshal(data, &msg)
678679
if err != nil {
680+
logger.Warn(ctx, "failed to unmarshal init", slog.F("raw", data))
679681
return
680682
}
681683
_ = a.handleReconnectingPTY(ctx, logger, msg, conn)
@@ -787,6 +789,7 @@ func (a *agent) runCoordinator(ctx context.Context, network *tailnet.Conn) error
787789
}
788790

789791
func (a *agent) runStartupScript(ctx context.Context, script string) error {
792+
a.logger.Debug(ctx, "running agent startup script")
790793
return a.runScript(ctx, "startup", script)
791794
}
792795

coderd/workspaceapps/apptest/setup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/stretchr/testify/assert"
1717
"github.com/stretchr/testify/require"
1818

19+
"cdr.dev/slog"
1920
"cdr.dev/slog/sloggers/slogtest"
2021
"github.com/coder/coder/agent"
2122
"github.com/coder/coder/coderd/coderdtest"
@@ -364,7 +365,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
364365
}
365366
agentCloser := agent.New(agent.Options{
366367
Client: agentClient,
367-
Logger: slogtest.Make(t, nil).Named("agent"),
368+
Logger: slogtest.Make(t, nil).Named("agent").Leveled(slog.LevelDebug),
368369
})
369370
t.Cleanup(func() {
370371
_ = agentCloser.Close()

0 commit comments

Comments
 (0)