Skip to content

Commit

Permalink
Merge pull request #8 from lunny/lunny/darwin_dup2
Browse files Browse the repository at this point in the history
fix build failed on darwin
  • Loading branch information
ngaut authored Mar 7, 2017
2 parents 1c9fb4d + d00894b commit d2af3a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crash_darwin.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 1 addition & 1 deletion crash_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build freebsd openbsd netbsd dragonfly darwin linux
// +build freebsd openbsd netbsd dragonfly linux

package log

Expand Down

0 comments on commit d2af3a6

Please sign in to comment.