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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user