diff --git a/terminal/terminal_check_bsd.go b/terminal_check_bsd.go similarity index 80% rename from terminal/terminal_check_bsd.go rename to terminal_check_bsd.go index 6a47df6d4..3c4f43f91 100644 --- a/terminal/terminal_check_bsd.go +++ b/terminal_check_bsd.go @@ -1,12 +1,12 @@ // +build darwin dragonfly freebsd netbsd openbsd -package terminal +package logrus import "golang.org/x/sys/unix" const ioctlReadTermios = unix.TIOCGETA -func IsTerminal(fd int) bool { +func isTerminal(fd int) bool { _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) return err == nil } diff --git a/terminal_check_notappengine.go b/terminal_check_notappengine.go index b61be8d55..7be2d87c5 100644 --- a/terminal_check_notappengine.go +++ b/terminal_check_notappengine.go @@ -5,14 +5,12 @@ package logrus import ( "io" "os" - - "github.com/sirupsen/logrus/terminal" ) func checkIfTerminal(w io.Writer) bool { switch v := w.(type) { case *os.File: - return terminal.IsTerminal(int(v.Fd())) + return isTerminal(int(v.Fd())) default: return false } diff --git a/terminal/terminal_check_unix.go b/terminal_check_unix.go similarity index 77% rename from terminal/terminal_check_unix.go rename to terminal_check_unix.go index f30ea8784..355dc966f 100644 --- a/terminal/terminal_check_unix.go +++ b/terminal_check_unix.go @@ -1,12 +1,12 @@ // +build linux aix -package terminal +package logrus import "golang.org/x/sys/unix" const ioctlReadTermios = unix.TCGETS -func IsTerminal(fd int) bool { +func isTerminal(fd int) bool { _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) return err == nil }