| David K. Bainbridge | 215e024 | 2017-09-05 23:18:24 -0700 | [diff] [blame] | 1 | // +build solaris,!appengine |
| 2 | |||||
| 3 | package logrus | ||||
| 4 | |||||
| 5 | import ( | ||||
| 6 | "io" | ||||
| 7 | "os" | ||||
| 8 | |||||
| 9 | "golang.org/x/sys/unix" | ||||
| 10 | ) | ||||
| 11 | |||||
| 12 | // IsTerminal returns true if the given file descriptor is a terminal. | ||||
| 13 | func IsTerminal(f io.Writer) bool { | ||||
| 14 | switch v := f.(type) { | ||||
| 15 | case *os.File: | ||||
| 16 | _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) | ||||
| 17 | return err == nil | ||||
| 18 | default: | ||||
| 19 | return false | ||||
| 20 | } | ||||
| 21 | } | ||||