Fix for CLICOLOR_FORCE handling

This commit is contained in:
David Bariod 2018-08-09 15:00:46 +02:00
parent 37d651c1f2
commit eb968b6506
1 changed files with 5 additions and 5 deletions

View File

@ -37,7 +37,7 @@ type TextFormatter struct {
DisableColors bool DisableColors bool
// Override coloring based on CLICOLOR and CLICOLOR_FORCE. - https://bixense.com/clicolors/ // Override coloring based on CLICOLOR and CLICOLOR_FORCE. - https://bixense.com/clicolors/
OverrideColors bool EnvironmentOverrideColors bool
// Disable timestamp logging. useful when output is redirected to logging // Disable timestamp logging. useful when output is redirected to logging
// system that already adds timestamps. // system that already adds timestamps.
@ -85,12 +85,12 @@ func (f *TextFormatter) init(entry *Entry) {
func (f *TextFormatter) isColored() bool { func (f *TextFormatter) isColored() bool {
isColored := f.ForceColors || f.isTerminal isColored := f.ForceColors || f.isTerminal
if f.OverrideColors { if f.EnvironmentOverrideColors {
if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" { if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {
isColored = true isColored = true
} } else if ok && force == "0" {
isColored = false
if os.Getenv("CLICOLOR") == "0" { } else if os.Getenv("CLICOLOR") == "0" {
isColored = false isColored = false
} }
} }