Add centralized command logging function

Refactors command execution to use a new log.Command helper that handles both logging and cmd creation, reducing duplication in sync.go
This commit is contained in:
AI Bot
2026-05-03 10:05:10 +02:00
committed by Riyyi
parent b1a376dbbe
commit d36bba6925
2 changed files with 17 additions and 25 deletions
+8
View File
@@ -4,7 +4,9 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)
@@ -43,6 +45,12 @@ func Write(msg []byte) {
logFile.Write(msg)
}
func Command(name string, args ...string) *exec.Cmd {
cmdStr := name + " " + strings.Join(args, " ")
fmt.Fprintf(logFile, "[cmd] %s\n", cmdStr)
return exec.Command(name, args...)
}
func Close() error {
if logFile == nil {
return nil