File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 66 "fmt"
77 "io"
88 "maps"
9+ "os"
910 "strings"
1011 "sync"
1112 "sync/atomic"
@@ -100,13 +101,17 @@ func ConfigureLogger(logger *logrus.Logger, cfg *Config) {
100101
101102 switch cfg .Format {
102103 case FormatTypeText :
104+ // Respect NO_COLOR env var (https://no-color.org/)
105+ noColor := os .Getenv ("NO_COLOR" ) != ""
106+
103107 logFormatter := & prefixed.TextFormatter {
104108 TimestampFormat : "2006-01-02 15:04:05" ,
105109 FullTimestamp : true ,
106110 ForceFormatting : true ,
107111 ForceColors : false ,
108112 QuoteEmptyFields : true ,
109113 DisableTimestamp : ! cfg .Timestamp ,
114+ DisableColors : noColor ,
110115 }
111116
112117 logFormatter .SetColorScheme (& prefixed.ColorScheme {
@@ -116,8 +121,12 @@ func ConfigureLogger(logger *logrus.Logger, cfg *Config) {
116121
117122 logger .SetFormatter (logFormatter )
118123
119- // Windows does not support ANSI colors
120- logger .SetOutput (colorable .NewColorableStdout ())
124+ if noColor {
125+ logger .SetOutput (os .Stdout )
126+ } else {
127+ // Windows does not support ANSI colors
128+ logger .SetOutput (colorable .NewColorableStdout ())
129+ }
121130
122131 case FormatTypeJson :
123132 logger .SetFormatter (& logrus.JSONFormatter {})
You can’t perform that action at this time.
0 commit comments