2017-07-11 11:51:21 +00:00
|
|
|
// +build solaris,!appengine
|
2016-02-13 00:50:37 +00:00
|
|
|
|
|
|
|
package logrus
|
|
|
|
|
|
|
|
import (
|
2017-07-11 11:51:21 +00:00
|
|
|
"io"
|
2016-02-13 00:50:37 +00:00
|
|
|
"os"
|
|
|
|
|
2016-08-09 23:42:51 +00:00
|
|
|
"golang.org/x/sys/unix"
|
2016-02-13 00:50:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
2017-07-11 11:51:21 +00:00
|
|
|
func IsTerminal(f io.Writer) bool {
|
|
|
|
switch v := f.(type) {
|
|
|
|
case *os.File:
|
|
|
|
_, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA)
|
|
|
|
return err == nil
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
2016-02-13 00:50:37 +00:00
|
|
|
}
|