Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit6389faf

Browse files
authored
feat: write agent output to a temporary file (#422)
1 parentccecc2f commit6389faf

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎internal/cmd/agent.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net/url"
55
"os"
66
"os/signal"
7+
"path/filepath"
78
"syscall"
89

910
// We use slog here since agent runs in the background and we can benefit
@@ -48,10 +49,20 @@ coder agent start
4849
coder agent start --coder-url https://my-coder.com --token xxxx-xxxx
4950
`,
5051
RunE:func(cmd*cobra.Command,args []string)error {
51-
var (
52-
ctx=cmd.Context()
53-
log=slog.Make(sloghuman.Sink(os.Stderr)).Leveled(slog.LevelDebug)
54-
)
52+
ctx:=cmd.Context()
53+
sinks:= []slog.Sink{
54+
sloghuman.Sink(os.Stderr),
55+
}
56+
57+
file,err:=os.OpenFile(filepath.Join(os.TempDir(),"coder-agent.log"),os.O_RDWR|os.O_CREATE|os.O_TRUNC,0600)
58+
iferr==nil&&file!=nil {
59+
sinks=append(sinks,sloghuman.Sink(file))
60+
}
61+
62+
log:=slog.Make(sinks...).Leveled(slog.LevelDebug)
63+
iferr!=nil {
64+
log.Info(ctx,"failed to open agent log file",slog.Error(err))
65+
}
5566
ifcoderURL=="" {
5667
varokbool
5768
coderURL,ok=os.LookupEnv("CODER_URL")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp