forked from cerc-io/plugeth
internal/debug: add log.logfmt flag to set logging to use logfmt (#26970)
This commit is contained in:
parent
fd94b4fcfa
commit
56c1f98f8a
@ -54,6 +54,11 @@ var (
|
|||||||
Usage: "Format logs with JSON",
|
Usage: "Format logs with JSON",
|
||||||
Category: flags.LoggingCategory,
|
Category: flags.LoggingCategory,
|
||||||
}
|
}
|
||||||
|
logfmtFlag = &cli.BoolFlag{
|
||||||
|
Name: "log.logfmt",
|
||||||
|
Usage: "Format logs with logfmt",
|
||||||
|
Category: flags.LoggingCategory,
|
||||||
|
}
|
||||||
logFileFlag = &cli.StringFlag{
|
logFileFlag = &cli.StringFlag{
|
||||||
Name: "log.file",
|
Name: "log.file",
|
||||||
Usage: "Write logs to a file",
|
Usage: "Write logs to a file",
|
||||||
@ -115,6 +120,7 @@ var Flags = []cli.Flag{
|
|||||||
verbosityFlag,
|
verbosityFlag,
|
||||||
vmoduleFlag,
|
vmoduleFlag,
|
||||||
logjsonFlag,
|
logjsonFlag,
|
||||||
|
logfmtFlag,
|
||||||
logFileFlag,
|
logFileFlag,
|
||||||
backtraceAtFlag,
|
backtraceAtFlag,
|
||||||
debugFlag,
|
debugFlag,
|
||||||
@ -147,6 +153,8 @@ func Setup(ctx *cli.Context) error {
|
|||||||
var logfmt log.Format
|
var logfmt log.Format
|
||||||
if ctx.Bool(logjsonFlag.Name) {
|
if ctx.Bool(logjsonFlag.Name) {
|
||||||
logfmt = log.JSONFormat()
|
logfmt = log.JSONFormat()
|
||||||
|
} else if ctx.Bool(logfmtFlag.Name) {
|
||||||
|
logfmt = log.LogfmtFormat()
|
||||||
} else {
|
} else {
|
||||||
logfmt = log.TerminalFormat(useColor)
|
logfmt = log.TerminalFormat(useColor)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user