Skip to content

Commit

Permalink
Merge pull request #921 from sosiska/patch-1
Browse files Browse the repository at this point in the history
Rewrite if-else-if-else to switch statements
  • Loading branch information
markphelps committed Mar 4, 2020
2 parents 334dd77 + 1487633 commit 53000c4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions text_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ func (f *TextFormatter) isColored() bool {
isColored := f.ForceColors || (f.isTerminal && (runtime.GOOS != "windows"))

if f.EnvironmentOverrideColors {
if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {
switch force, ok := os.LookupEnv("CLICOLOR_FORCE"); {
case ok && force != "0":
isColored = true
} else if ok && force == "0" {
isColored = false
} else if os.Getenv("CLICOLOR") == "0" {
case ok && force == "0", os.Getenv("CLICOLOR") == "0":
isColored = false
}
}
Expand Down Expand Up @@ -271,11 +270,12 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin
}
}

if f.DisableTimestamp {
switch {
case f.DisableTimestamp:
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m%s %-44s ", levelColor, levelText, caller, entry.Message)
} else if !f.FullTimestamp {
case !f.FullTimestamp:
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d]%s %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), caller, entry.Message)
} else {
default:
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s]%s %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), caller, entry.Message)
}
for _, k := range keys {
Expand Down

0 comments on commit 53000c4

Please sign in to comment.