aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/exec.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-03 22:47:18 +0900
committerOphestra <cat@gensokyo.uk>2026-03-04 17:27:54 +0900
commit94e3debc632b6f3f309218395339ca0e9ba754b7 (patch)
treef975d1274d186c19fb3b5f4047a6e1d894720fbb /internal/pkg/exec.go
parentea87664a759991a14c6891d53a488e3b7af26ee8 (diff)
internal/pkg: write per-artifact logs
This is currently only used by execArtifact. A later patch will add additional logging facilities. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec.go')
-rw-r--r--internal/pkg/exec.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go
index bc068d1e..e06ec32e 100644
--- a/internal/pkg/exec.go
+++ b/internal/pkg/exec.go
@@ -418,6 +418,12 @@ func (a *execArtifact) cure(f *FContext, hostNet bool) (err error) {
z.Hostname = "cure-net"
}
z.Uid, z.Gid = (1<<10)-1, (1<<10)-1
+
+ var status io.Writer
+ if status, err = f.GetStatusWriter(); err != nil {
+ return
+ }
+
if msg := f.GetMessage(); msg.IsVerbose() {
var stdout, stderr io.ReadCloser
if stdout, err = z.StdoutPipe(); err != nil {
@@ -434,10 +440,29 @@ func (a *execArtifact) cure(f *FContext, hostNet bool) (err error) {
}
}()
+ bw := f.cache.getWriter(status)
+ defer func() {
+ flushErr := bw.Flush()
+ if err == nil {
+ err = flushErr
+ }
+ f.cache.putWriter(bw)
+ }()
+
stdoutDone, stderrDone := make(chan struct{}), make(chan struct{})
- go scanVerbose(msg, cancel, stdoutDone, "("+a.name+":1)", stdout)
- go scanVerbose(msg, cancel, stderrDone, "("+a.name+":2)", stderr)
+ go scanVerbose(
+ msg, cancel, stdoutDone,
+ "("+a.name+":1)",
+ io.TeeReader(stdout, bw),
+ )
+ go scanVerbose(
+ msg, cancel, stderrDone,
+ "("+a.name+":2)",
+ io.TeeReader(stderr, bw),
+ )
defer func() { <-stdoutDone; <-stderrDone }()
+ } else {
+ z.Stdout, z.Stderr = status, status
}
z.Dir, z.Env, z.Path, z.Args = a.dir, a.env, a.path, a.args