mirror of https://github.com/Xhofe/alist
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.pull/9247/head
parent
394a18cbd9
commit
ae90fb579b
|
@ -14,10 +14,14 @@ import (
|
|||
|
||||
func init() {
|
||||
formatter := logrus.TextFormatter{
|
||||
ForceColors: true,
|
||||
EnvironmentOverrideColors: true,
|
||||
TimestampFormat: "2006-01-02 15:04:05",
|
||||
FullTimestamp: true,
|
||||
TimestampFormat: "2006-01-02 15:04:05",
|
||||
FullTimestamp: true,
|
||||
}
|
||||
if os.Getenv("NO_COLOR") != "" || os.Getenv("ALIST_NO_COLOR") == "1" {
|
||||
formatter.DisableColors = true
|
||||
} else {
|
||||
formatter.ForceColors = true
|
||||
formatter.EnvironmentOverrideColors = true
|
||||
}
|
||||
logrus.SetFormatter(&formatter)
|
||||
utils.Log.SetFormatter(&formatter)
|
||||
|
|
Loading…
Reference in New Issue