robocar-throttle/vendor/github.com/sirupsen/logrus/terminal_check_windows.go

28 lines
490 B
Go
Raw Normal View History

2020-01-01 18:36:22 +00:00
// +build !appengine,!js,windows
package logrus
import (
"io"
"os"
2020-03-01 18:44:59 +00:00
"golang.org/x/sys/windows"
2020-01-01 18:36:22 +00:00
)
func checkIfTerminal(w io.Writer) bool {
switch v := w.(type) {
case *os.File:
handle := windows.Handle(v.Fd())
2020-01-01 18:36:22 +00:00
var mode uint32
if err := windows.GetConsoleMode(handle, &mode); err != nil {
return false
}
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
if err := windows.SetConsoleMode(handle, mode); err != nil {
return false
}
return true
2020-01-01 18:36:22 +00:00
}
return false
2020-01-01 18:36:22 +00:00
}