util: We prefer to append rather than truncate

This makes this utility function more useful.
This commit is contained in:
James Shubin
2024-10-29 16:37:55 -04:00
parent 8c886bbe7c
commit 8e3d959500

View File

@@ -32,7 +32,6 @@ package util
import ( import (
"bytes" "bytes"
"context" "context"
"os"
"os/exec" "os/exec"
"strings" "strings"
"syscall" "syscall"
@@ -83,7 +82,7 @@ func SimpleCmd(ctx context.Context, name string, args []string, opts *SimpleCmdO
out := b.String() out := b.String()
if opts != nil && opts.LogOutput != "" { if opts != nil && opts.LogOutput != "" {
if err := os.WriteFile(opts.LogOutput, b.Bytes(), 0600); err != nil { if err := AppendFile(opts.LogOutput, b.Bytes(), 0600); err != nil {
logf("unable to store log: %v", err) logf("unable to store log: %v", err)
} else { } else {
logf("wrote log to: %s", opts.LogOutput) logf("wrote log to: %s", opts.LogOutput)