terminal_check_windows.go 297 B

1234567891011121314151617181920
  1. // +build !appengine,!js,windows
  2. package logrus
  3. import (
  4. "io"
  5. "os"
  6. "syscall"
  7. )
  8. func checkIfTerminal(w io.Writer) bool {
  9. switch v := w.(type) {
  10. case *os.File:
  11. var mode uint32
  12. err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode)
  13. return err == nil
  14. default:
  15. return false
  16. }
  17. }