Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/debug: Add log.logfmt flag to set logging to use logfmt #26970

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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