Add a function to force color in console output (#1724)

Add a function `ForceConsoleColor`, like `DisableConsoleColor` but to force coloring the output.

It usefull when some IDE's integrated console (like IntelliJ or Goland) are not detected as TTY, but can display colors.

Also helps if one want to output color in log file (#1590) and as a workaround for #1547.
This commit is contained in:
Olivier Robardet
2019-02-20 14:14:16 +01:00
committed by Bo-Yi Wu
parent 90587c7787
commit a58a2f9bf3
3 changed files with 57 additions and 5 deletions

View File

@ -340,3 +340,10 @@ func TestDisableConsoleColor(t *testing.T) {
DisableConsoleColor()
assert.True(t, disableColor)
}
func TestForceConsoleColor(t *testing.T) {
New()
assert.False(t, forceColor)
ForceConsoleColor()
assert.True(t, forceColor)
}