aboutsummaryrefslogtreecommitdiff
path: root/internal/tlog
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-12-11 15:35:01 +0100
committerJakob Unterwurzacher2021-12-11 15:35:01 +0100
commita1f01419e2e6e5d637ec7afa31c0a1d95e0ea923 (patch)
treeb48af93936aef85a88fbfe95bd60459d8f8811b4 /internal/tlog
parentbd1ecf537983ee5207e78f9bcd6a6ae50c1b4c62 (diff)
tlog: respect NO_COLOR
Fixes https://github.com/rfjakob/gocryptfs/issues/617
Diffstat (limited to 'internal/tlog')
-rw-r--r--internal/tlog/log.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/tlog/log.go b/internal/tlog/log.go
index 5535ef3..3f27539 100644
--- a/internal/tlog/log.go
+++ b/internal/tlog/log.go
@@ -106,7 +106,9 @@ var Warn *toggledLogger
var Fatal *toggledLogger
func init() {
- if term.IsTerminal(int(os.Stdout.Fd())) {
+ // 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())) {
ColorReset = "\033[0m"
ColorGrey = "\033[2m"
ColorRed = "\033[31m"