log/crash/crash_darwin.go

22 lines
354 B
Go
Raw Normal View History

2019-11-05 07:57:09 +00:00
// +build darwin
package crash
import (
"log"
"os"
"syscall"
"github.com/pkg/errors"
)
// CrashLog set crash log
func CrashLog(file string) {
f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("open crash log file error. %v", errors.WithStack(err))
} else {
syscall.Dup2(int(f.Fd()), 2)
}
}