Skip to content

Commit ae90fb5

Browse files
authored
feat(log): enhance log formatter to respect NO_COLOR env variable (#9239)
- Adjust log formatter to disable colors when NO_COLOR or ALIST_NO_COLOR environment variables are set. - Reorganize formatter settings for better readability.
1 parent 394a18c commit ae90fb5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/bootstrap/log.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ import (
1414

1515
func init() {
1616
formatter := logrus.TextFormatter{
17-
ForceColors: true,
18-
EnvironmentOverrideColors: true,
19-
TimestampFormat: "2006-01-02 15:04:05",
20-
FullTimestamp: true,
17+
TimestampFormat: "2006-01-02 15:04:05",
18+
FullTimestamp: true,
19+
}
20+
if os.Getenv("NO_COLOR") != "" || os.Getenv("ALIST_NO_COLOR") == "1" {
21+
formatter.DisableColors = true
22+
} else {
23+
formatter.ForceColors = true
24+
formatter.EnvironmentOverrideColors = true
2125
}
2226
logrus.SetFormatter(&formatter)
2327
utils.Log.SetFormatter(&formatter)

0 commit comments

Comments
 (0)