Added terminal check on Windows

This commit is contained in:
Felix Kollmann 2018-04-03 04:40:58 +02:00
parent 7d2a5214bf
commit c9a46a1e7c
2 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// +build !appengine,!gopherjs // +build !appengine,!gopherjs,!windows
package logrus package logrus

20
terminal_check_windows.go Normal file
View File

@ -0,0 +1,20 @@
// +build !appengine,!gopherjs,windows
package logrus
import (
"io"
"os"
"syscall"
)
func checkIfTerminal(w io.Writer) bool {
switch v := w.(type) {
case *os.File:
var mode uint32
err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode)
return err == nil
default:
return false
}
}