Support google appengine for IsTerminal func.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-12-04 09:50:02 +08:00
parent 0f80d5ddea
commit 38e4b1d2fe
1 changed files with 3 additions and 6 deletions

View File

@ -8,10 +8,9 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"runtime"
"time" "time"
"golang.org/x/crypto/ssh/terminal" "github.com/mattn/go-isatty"
) )
var ( var (
@ -50,10 +49,8 @@ func Logger() HandlerFunc {
func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc { func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
isTerm := true isTerm := true
if runtime.GOOS != "appengine" && runtime.GOOS != "netbsd" && runtime.GOOS != "openbsd" { if w, ok := out.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
if outFile, ok := out.(*os.File); ok { isTerm = false
isTerm = terminal.IsTerminal(int(outFile.Fd()))
}
} }
var skip map[string]struct{} var skip map[string]struct{}