mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 05:54:43 +02:00
Add --log-file flag to log everything (including panics) to file
This commit is contained in:
19
redirect_stderr_unix.go
Normal file
19
redirect_stderr_unix.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Log the panic under unix to the log file
|
||||
|
||||
//+build unix
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// redirectStderr to the file passed in
|
||||
func redirectStderr(f *os.File) {
|
||||
err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to redirect stderr to file: %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user