forked from mirror/logrus
Merge pull request #864 from ceriath/patch-1
Remove colored output on windows
This commit is contained in:
commit
9f049671f1
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -90,7 +91,7 @@ func (f *TextFormatter) init(entry *Entry) {
|
|||
}
|
||||
|
||||
func (f *TextFormatter) isColored() bool {
|
||||
isColored := f.ForceColors || f.isTerminal
|
||||
isColored := f.ForceColors || (f.isTerminal && (runtime.GOOS != "windows"))
|
||||
|
||||
if f.EnvironmentOverrideColors {
|
||||
if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -443,7 +444,11 @@ func TestTextFormatterIsColored(t *testing.T) {
|
|||
os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal)
|
||||
}
|
||||
res := tf.isColored()
|
||||
if runtime.GOOS == "windows" && !tf.ForceColors && !val.clicolorForceIsSet {
|
||||
assert.Equal(subT, false, res)
|
||||
} else {
|
||||
assert.Equal(subT, val.expectedResult, res)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue