mirror of
https://github.com/containrrr/watchtower.git
synced 2025-03-03 15:32:37 +02:00
Disabling color through environment variables (#598)
* This patch adds support for disabling color through environment variables.
- NO_COLOR: https://no-color.org/
- CLICOLOR,CLICOLOR_FORCE: https://bixense.com/clicolors/ ( [logrus built-in](6699a89a23/text_formatter.go (L46)
) )
* use viper/cobra and add documentation. (https://github.com/containrrr/watchtower/pull/598#pullrequestreview-463814669)
Co-authored-by: Simon Aronsson <simme@arcticbit.se>
This commit is contained in:
parent
9bd3913a11
commit
158b6935d4
11
cmd/root.go
11
cmd/root.go
@ -63,6 +63,17 @@ func Execute() {
|
||||
func PreRun(cmd *cobra.Command, args []string) {
|
||||
f := cmd.PersistentFlags()
|
||||
|
||||
if enabled, _ := f.GetBool("no-color"); enabled {
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
DisableColors: true,
|
||||
})
|
||||
} else {
|
||||
// enable logrus built-in support for https://bixense.com/clicolors/
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
EnvironmentOverrideColors: true,
|
||||
})
|
||||
}
|
||||
|
||||
if enabled, _ := f.GetBool("debug"); enabled {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
@ -88,6 +88,16 @@ Environment Variable: WATCHTOWER_TRACE
|
||||
Default: false
|
||||
```
|
||||
|
||||
## ANSI colors
|
||||
Disable ANSI color escape codes in log output.
|
||||
|
||||
```
|
||||
Argument: --no-color
|
||||
Environment Variable: NO_COLOR
|
||||
Type: Boolean
|
||||
Default: false
|
||||
```
|
||||
|
||||
## Docker host
|
||||
Docker daemon socket to connect to. Can be pointed at a remote Docker host by specifying a TCP endpoint as "tcp://hostname:port".
|
||||
|
||||
|
@ -140,7 +140,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
|
||||
"",
|
||||
viper.GetString("WATCHTOWER_HTTP_API_TOKEN"),
|
||||
"Sets an authentication token to HTTP API requests.")
|
||||
|
||||
// https://no-color.org/
|
||||
flags.BoolP(
|
||||
"no-color",
|
||||
"",
|
||||
viper.IsSet("NO_COLOR"),
|
||||
"Disable ANSI color escape codes in log output")
|
||||
flags.StringP(
|
||||
"scope",
|
||||
"",
|
||||
|
Loading…
x
Reference in New Issue
Block a user