Merge pull request #943 from tandr/unexport-isterminal

Unexport IsTerminal
This commit is contained in:
David Bariod 2019-04-02 09:14:47 +02:00 committed by GitHub
commit 8fe117bf7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -1,12 +1,12 @@
// +build darwin dragonfly freebsd netbsd openbsd // +build darwin dragonfly freebsd netbsd openbsd
package terminal package logrus
import "golang.org/x/sys/unix" import "golang.org/x/sys/unix"
const ioctlReadTermios = unix.TIOCGETA const ioctlReadTermios = unix.TIOCGETA
func IsTerminal(fd int) bool { func isTerminal(fd int) bool {
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios) _, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil return err == nil
} }

View File

@ -5,14 +5,12 @@ package logrus
import ( import (
"io" "io"
"os" "os"
"github.com/sirupsen/logrus/terminal"
) )
func checkIfTerminal(w io.Writer) bool { func checkIfTerminal(w io.Writer) bool {
switch v := w.(type) { switch v := w.(type) {
case *os.File: case *os.File:
return terminal.IsTerminal(int(v.Fd())) return isTerminal(int(v.Fd()))
default: default:
return false return false
} }

View File

@ -1,12 +1,12 @@
// +build linux aix // +build linux aix
package terminal package logrus
import "golang.org/x/sys/unix" import "golang.org/x/sys/unix"
const ioctlReadTermios = unix.TCGETS const ioctlReadTermios = unix.TCGETS
func IsTerminal(fd int) bool { func isTerminal(fd int) bool {
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios) _, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil return err == nil
} }