From 913aefba2a549b6024ef16f8c3fe297176434a83 Mon Sep 17 00:00:00 2001 From: Ellaismer Date: Sat, 30 Dec 2017 04:01:09 -0500 Subject: [PATCH] Use colorable windows output --- logger/glog/glog.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/logger/glog/glog.go b/logger/glog/glog.go index 036ad105..542dbf36 100644 --- a/logger/glog/glog.go +++ b/logger/glog/glog.go @@ -91,6 +91,8 @@ import ( "sync" "sync/atomic" "time" + + "github.com/mattn/go-colorable" ) // DefaultVerbosity establishes the default verbosity Level for @@ -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{ @@ -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) } }