Skip to content

Commit

Permalink
remove os-specific IsTerminal methods, and use x/crypto/ssh/terminal …
Browse files Browse the repository at this point in the history
…instead
  • Loading branch information
dmathieu committed Jul 27, 2017
1 parent 9aa7601 commit e66f229
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 144 deletions.
10 changes: 0 additions & 10 deletions terminal_appengine.go

This file was deleted.

29 changes: 0 additions & 29 deletions terminal_notwindows.go

This file was deleted.

21 changes: 0 additions & 21 deletions terminal_solaris.go

This file was deleted.

83 changes: 0 additions & 83 deletions terminal_windows.go

This file was deleted.

15 changes: 14 additions & 1 deletion text_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package logrus
import (
"bytes"
"fmt"
"io"
"os"
"sort"
"strings"
"sync"
"time"

"golang.org/x/crypto/ssh/terminal"
)

const (
Expand Down Expand Up @@ -61,7 +65,16 @@ type TextFormatter struct {

func (f *TextFormatter) init(entry *Entry) {
if entry.Logger != nil {
f.isTerminal = IsTerminal(entry.Logger.Out)
f.isTerminal = f.checkIfTerminal(entry.Logger.Out)
}
}

func (f *TextFormatter) checkIfTerminal(w io.Writer) bool {
switch v := w.(type) {
case *os.File:
return terminal.IsTerminal(int(v.Fd()))
default:
return false
}
}

Expand Down

0 comments on commit e66f229

Please sign in to comment.