Skip to content

Commit

Permalink
internal/debug: add log.logfmt flag to set logging to use logfmt (#26970
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ajsutton authored Mar 28, 2023
1 parent fd94b4f commit 56c1f98
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ var (
Usage: "Format logs with JSON",
Category: flags.LoggingCategory,
}
logfmtFlag = &cli.BoolFlag{
Name: "log.logfmt",
Usage: "Format logs with logfmt",
Category: flags.LoggingCategory,
}
logFileFlag = &cli.StringFlag{
Name: "log.file",
Usage: "Write logs to a file",
Expand Down Expand Up @@ -115,6 +120,7 @@ var Flags = []cli.Flag{
verbosityFlag,
vmoduleFlag,
logjsonFlag,
logfmtFlag,
logFileFlag,
backtraceAtFlag,
debugFlag,
Expand Down Expand Up @@ -147,6 +153,8 @@ func Setup(ctx *cli.Context) error {
var logfmt log.Format
if ctx.Bool(logjsonFlag.Name) {
logfmt = log.JSONFormat()
} else if ctx.Bool(logfmtFlag.Name) {
logfmt = log.LogfmtFormat()
} else {
logfmt = log.TerminalFormat(useColor)
}
Expand Down

0 comments on commit 56c1f98

Please sign in to comment.