tlog: only enable color if both stderr and stdout are a terminal
This gocryptfs -init /does/not/exist 2> err.log used to write escape codes into err.log. Stop doing that.
This commit is contained in:
parent
a1f01419e2
commit
eb42e54182
@ -108,7 +108,9 @@ var Fatal *toggledLogger
|
|||||||
func init() {
|
func init() {
|
||||||
// Enable color output if we are connected to a terminal and NO_COLOR is
|
// Enable color output if we are connected to a terminal and NO_COLOR is
|
||||||
// unset ( https://no-color.org/ ).
|
// unset ( https://no-color.org/ ).
|
||||||
if _, nocolor := os.LookupEnv("NO_COLOR"); !nocolor && term.IsTerminal(int(os.Stdout.Fd())) {
|
if _, nocolor := os.LookupEnv("NO_COLOR"); !nocolor &&
|
||||||
|
term.IsTerminal(int(os.Stdout.Fd())) &&
|
||||||
|
term.IsTerminal(int(os.Stderr.Fd())) {
|
||||||
ColorReset = "\033[0m"
|
ColorReset = "\033[0m"
|
||||||
ColorGrey = "\033[2m"
|
ColorGrey = "\033[2m"
|
||||||
ColorRed = "\033[31m"
|
ColorRed = "\033[31m"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user