xmtop/logging/logging_windows.go
2020-02-17 13:00:52 -06:00

19 lines
379 B
Go

// +build windows
package logging
import (
"os"
"syscall"
)
var (
kernel32 = syscall.MustLoadDLL("kernel32.dll")
procSetStdHandle = kernel32.MustFindProc("SetStdHandle")
)
func stderrToLogfile(logfile *os.File) {
// https://groups.google.com/d/msg/golang-nuts/fG8hEAs7ZXs/tahEOuCEPn0J.
syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(logfile.Fd()), 2, 0)
}