Skip to content
Myr

Support google appengine for IsTerminal func.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Bo-Yi Wu · committed by Bo-Yi Wu · parent 0f80d5d · Browse files · 1 file+3 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Diff stats

1 file+3 added−6 removed

  • other:+3 added−6 removed

1 file+3 added−6 removed

modified:logger.go+3 added-6 removed
6 unmodified lines
7import (8 "fmt"9 "io"10 "os"11 "runtime"11 "time"1214 "golang.org/x/crypto/ssh/terminal"13 "github.com/mattn/go-isatty"14)1516var (17 green = string([]byte{27, 91, 57, 55, 59, 52, 50, 109})
30 unmodified lines
48// Example: os.Stdout, a file opened in write mode, a socket...49func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {50 isTerm := true5153 if runtime.GOOS != "appengine" && runtime.GOOS != "netbsd" && runtime.GOOS != "openbsd" {54 if outFile, ok := out.(*os.File); ok {55 isTerm = terminal.IsTerminal(int(outFile.Fd()))56 }52 if w, ok := out.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {53 isTerm = false54 }5556 var skip map[string]struct{}57
78 unmodified lines