Skip to content

Commit

Permalink
Use colorable windows output
Browse files Browse the repository at this point in the history
  • Loading branch information
ellaismer committed Dec 30, 2017
1 parent c6f6a59 commit 913aefb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions logger/glog/glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ import (
"sync"
"sync/atomic"
"time"

"github.com/mattn/go-colorable"
)

// DefaultVerbosity establishes the default verbosity Level for
Expand Down Expand Up @@ -147,6 +149,8 @@ var severityName = []string{
fatalLog: "FATAL",
}

var displayStderr = colorable.NewColorableStderr()

// these path prefixes are trimmed for display, but not when
// matching vmodule filters.
var trimPrefixes = []string{
Expand Down Expand Up @@ -889,14 +893,14 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
}
data := buf.Bytes()
if l.toStderr {
os.Stderr.Write(data)
displayStderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
os.Stderr.Write(data)
displayStderr.Write(data)
}
if l.file[s] == nil {
if err := l.createFiles(s); err != nil {
os.Stderr.Write(data) // Make sure the message appears somewhere.
displayStderr.Write(data) // Make sure the message appears somewhere.
l.exit(err)
}
}
Expand Down

0 comments on commit 913aefb

Please sign in to comment.