Skip to content

Commit 36bc01f

Browse files
authored
add color flag for text log (#871)
* add color flag for text log * improv docs
1 parent 1091e3d commit 36bc01f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ Usage of mev-boost:
252252
use Hoodi
253253
-json
254254
log in JSON format instead of text
255+
-color
256+
enable colored output for text log format; has no effect if JSON logging is enabled via -json
255257
-log-no-version
256258
disables adding the version to every log entry
257259
-log-service string

cli/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var flags = []cli.Flag{
1616
versionFlag,
1717
// logging
1818
jsonFlag,
19+
colorFlag,
1920
debugFlag,
2021
logLevelFlag,
2122
logServiceFlag,
@@ -63,6 +64,12 @@ var (
6364
Usage: "log in JSON format instead of text",
6465
Category: LoggingCategory,
6566
}
67+
colorFlag = &cli.BoolFlag{
68+
Name: "color",
69+
Sources: cli.EnvVars("LOG_COLOR"),
70+
Usage: "enable colored output for text log format",
71+
Category: LoggingCategory,
72+
}
6673
debugFlag = &cli.BoolFlag{
6774
Name: "debug",
6875
Sources: cli.EnvVars("DEBUG"),

cli/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func setupLogging(cmd *cli.Command) error {
184184
log.Logger.SetFormatter(&logrus.TextFormatter{
185185
FullTimestamp: true,
186186
TimestampFormat: config.RFC3339Milli,
187-
ForceColors: true,
187+
ForceColors: cmd.Bool(colorFlag.Name),
188188
})
189189
}
190190

0 commit comments

Comments
 (0)