diff --git a/log/log.go b/log/log.go index 4036d9d..09d2acd 100644 --- a/log/log.go +++ b/log/log.go @@ -5,7 +5,6 @@ import ( "log" "log/syslog" "os" - "syscall" ) type Logger struct { @@ -52,18 +51,4 @@ func Reopen() { Log.Notice("Reopened log file per IPC request") } -// If there are any existing fd's (e.g. we're reopening logs), we rely -// on garbage collection to clean them up for us. -func LogRedirectStdOutToFile(logPath string) { - path = logPath - if logPath == "" { - Log.Fatal("Log Path not set") - } - logFile, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) - if err != nil { - Log.Fatal(err) - } - syscall.Dup2(int(logFile.Fd()), 1) - syscall.Dup2(int(logFile.Fd()), 2) -} diff --git a/log/log_redirect.go b/log/log_redirect.go new file mode 100644 index 0000000..d0573d1 --- /dev/null +++ b/log/log_redirect.go @@ -0,0 +1,25 @@ +// +build !arm64 + +package log + +import ( + "os" + "syscall" +) + +// If there are any existing fd's (e.g. we're reopening logs), we rely +// on garbage collection to clean them up for us. +func LogRedirectStdOutToFile(logPath string) { + path = logPath + if logPath == "" { + Log.Fatal("Log Path not set") + } + + logFile, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + if err != nil { + Log.Fatal(err) + } + + syscall.Dup2(int(logFile.Fd()), 1) + syscall.Dup2(int(logFile.Fd()), 2) +} \ No newline at end of file diff --git a/log/log_redirect_arm64.go b/log/log_redirect_arm64.go new file mode 100644 index 0000000..bb6a66f --- /dev/null +++ b/log/log_redirect_arm64.go @@ -0,0 +1,23 @@ +package log + +import ( + "os" + "syscall" +) + +// If there are any existing fd's (e.g. we're reopening logs), we rely +// on garbage collection to clean them up for us. +func LogRedirectStdOutToFile(logPath string) { + path = logPath + if logPath == "" { + Log.Fatal("Log Path not set") + } + + logFile, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + if err != nil { + Log.Fatal(err) + } + + syscall.Dup3(int(logFile.Fd()), 1, 0) + syscall.Dup3(int(logFile.Fd()), 2, 0) +} \ No newline at end of file