2019-03-26 19:19:59 +03:00
|
|
|
// +build !appengine,!js,!windows
|
2017-09-06 20:34:58 +03:00
|
|
|
|
|
|
|
package logrus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
|
2019-03-26 19:19:59 +03:00
|
|
|
"golang.org/x/sys/unix"
|
2017-09-06 20:34:58 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func checkIfTerminal(w io.Writer) bool {
|
|
|
|
switch v := w.(type) {
|
|
|
|
case *os.File:
|
2019-03-26 19:19:59 +03:00
|
|
|
_, err := unix.IoctlGetTermios(int(v.Fd()), ioctlReadTermios)
|
|
|
|
|
|
|
|
return err == nil
|
2017-09-06 20:34:58 +03:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|