Add --syslog flag to optionally log to syslog on capable platforms

This commit is contained in:
Nick Craig-Wood
2017-02-11 20:27:46 +00:00
parent ac1c041377
commit 666dae4229
10 changed files with 179 additions and 59 deletions
+20
View File
@@ -0,0 +1,20 @@
// Log the panic under unix to the log file
// +build !windows,!solaris,!plan9
package fs
import (
"log"
"os"
"golang.org/x/sys/unix"
)
// redirectStderr to the file passed in
func redirectStderr(f *os.File) {
err := unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
if err != nil {
log.Fatalf("Failed to redirect stderr to file: %v", err)
}
}