From d00894bb9e68d640e2cda34c2b0a371187bf3cd1 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 7 Mar 2017 09:06:47 +0800 Subject: [PATCH] fix build failed on darwin --- crash_darwin.go | 18 ++++++++++++++++++ crash_unix.go | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 crash_darwin.go diff --git a/crash_darwin.go b/crash_darwin.go new file mode 100644 index 0000000..14ce559 --- /dev/null +++ b/crash_darwin.go @@ -0,0 +1,18 @@ +// +build darwin + +package log + +import ( + "log" + "os" + "syscall" +) + +func CrashLog(file string) { + f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + log.Println(err.Error()) + } else { + syscall.Dup2(int(f.Fd()), 2) + } +} diff --git a/crash_unix.go b/crash_unix.go index c5042b9..5b9bc23 100644 --- a/crash_unix.go +++ b/crash_unix.go @@ -1,4 +1,4 @@ -// +build freebsd openbsd netbsd dragonfly darwin linux +// +build freebsd openbsd netbsd dragonfly linux package log