summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/sirupsen/logrus/terminal_notwindows.go
diff options
context:
space:
mode:
authorLukas Macko <lmacko@cisco.com>2017-09-07 12:45:41 +0200
committerLukas Macko <lmacko@cisco.com>2017-09-07 12:45:41 +0200
commitd07761baec9f09aef0b140ea46e38bd597dbdbbc (patch)
tree406a35de6a2b8d3b5373a917394988b2a8b8f5a7 /vendor/github.com/sirupsen/logrus/terminal_notwindows.go
parentf2cbe790a5c3c3e8cb59b592c252b2b84025bd91 (diff)
import sirupsen with lowercase
Change-Id: I555587fc9ecc074ea1a42f0dc77c11716a1b06cb Signed-off-by: Lukas Macko <lmacko@cisco.com>
Diffstat (limited to 'vendor/github.com/sirupsen/logrus/terminal_notwindows.go')
-rw-r--r--vendor/github.com/sirupsen/logrus/terminal_notwindows.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/sirupsen/logrus/terminal_notwindows.go
new file mode 100644
index 0000000..190297a
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/terminal_notwindows.go
@@ -0,0 +1,28 @@
+// Based on ssh/terminal:
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux darwin freebsd openbsd netbsd dragonfly
+// +build !appengine
+
+package logrus
+
+import (
+ "io"
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+// IsTerminal returns true if stderr's file descriptor is a terminal.
+func IsTerminal(f io.Writer) bool {
+ var termios Termios
+ switch v := f.(type) {
+ case *os.File:
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+ default:
+ return false
+ }
+}