diff options
author | Jakob Unterwurzacher | 2021-12-11 15:37:13 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2021-12-11 15:37:13 +0100 |
commit | eb42e541828336e9b19e1bc5e087a419835b0c85 (patch) | |
tree | cdc2d902a5a4304a5039f6bc0dfae18e63fe9fbb /internal/tlog | |
parent | a1f01419e2e6e5d637ec7afa31c0a1d95e0ea923 (diff) |
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.
Diffstat (limited to 'internal/tlog')
-rw-r--r-- | internal/tlog/log.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/tlog/log.go b/internal/tlog/log.go index 3f27539..62d791d 100644 --- a/internal/tlog/log.go +++ b/internal/tlog/log.go @@ -108,7 +108,9 @@ var Fatal *toggledLogger func init() { // Enable color output if we are connected to a terminal and NO_COLOR is // 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" ColorGrey = "\033[2m" ColorRed = "\033[31m" |