summaryrefslogtreecommitdiffstats
path: root/logging/logging_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'logging/logging_windows.go')
-rw-r--r--logging/logging_windows.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/logging/logging_windows.go b/logging/logging_windows.go
new file mode 100644
index 0000000..65a2e55
--- /dev/null
+++ b/logging/logging_windows.go
@@ -0,0 +1,18 @@
+// +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)
+}