From 56c1f98f8acfcc79e4348ba3aeecd3ea2e0c9a84 Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Tue, 28 Mar 2023 22:37:40 +1000 Subject: [PATCH] internal/debug: add log.logfmt flag to set logging to use logfmt (#26970) --- internal/debug/flags.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/debug/flags.go b/internal/debug/flags.go index e014a85d7fc8..0bae9883ec3b 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -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", @@ -115,6 +120,7 @@ var Flags = []cli.Flag{ verbosityFlag, vmoduleFlag, logjsonFlag, + logfmtFlag, logFileFlag, backtraceAtFlag, debugFlag, @@ -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) }