mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/geth: in logtest command, reset root logger before starting test output to clear field padding map. make LogFormatFlag public from internal/debug package.
This commit is contained in:
parent
3ab42db894
commit
8632783dcb
2 changed files with 11 additions and 4 deletions
|
|
@ -23,9 +23,11 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/internal/debug"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
|
@ -49,6 +51,11 @@ func (c customQuotedStringer) String() string {
|
|||
// logTest is an entry point which spits out some logs. This is used by testing
|
||||
// to verify expected outputs
|
||||
func logTest(ctx *cli.Context) error {
|
||||
// if log is set to output terminal format, reset root logger to clear field padding map
|
||||
if !ctx.IsSet(debug.LogFormatFlag.Name) || ctx.String(debug.LogFormatFlag.Name) == "terminal" {
|
||||
log.SetDefault(log.NewLogger(log.TerminalHandler(os.Stdout, false)))
|
||||
}
|
||||
|
||||
{ // big.Int
|
||||
ba, _ := new(big.Int).SetString("111222333444555678999", 10) // "111,222,333,444,555,678,999"
|
||||
bb, _ := new(big.Int).SetString("-111222333444555678999", 10) // "-111,222,333,444,555,678,999"
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ var (
|
|||
Hidden: true,
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
logFormatFlag = &cli.StringFlag{
|
||||
LogFormatFlag = &cli.StringFlag{
|
||||
Name: "log.format",
|
||||
Usage: "Log format to use (json|logfmt|terminal)",
|
||||
Category: flags.LoggingCategory,
|
||||
|
|
@ -151,7 +151,7 @@ var Flags = []cli.Flag{
|
|||
logVmoduleFlag,
|
||||
vmoduleFlag,
|
||||
logjsonFlag,
|
||||
logFormatFlag,
|
||||
LogFormatFlag,
|
||||
logFileFlag,
|
||||
logRotateFlag,
|
||||
logMaxSizeMBsFlag,
|
||||
|
|
@ -186,7 +186,7 @@ func Setup(ctx *cli.Context) error {
|
|||
fileOutput io.Writer
|
||||
terminalOutput = io.Writer(os.Stderr)
|
||||
output io.Writer
|
||||
logFmtFlag = ctx.String(logFormatFlag.Name)
|
||||
logFmtFlag = ctx.String(LogFormatFlag.Name)
|
||||
)
|
||||
var (
|
||||
logFile = ctx.String(logFileFlag.Name)
|
||||
|
|
@ -252,7 +252,7 @@ func Setup(ctx *cli.Context) error {
|
|||
handler = log.TerminalHandler(output, useColor)
|
||||
default:
|
||||
// Unknown log format specified
|
||||
return fmt.Errorf("unknown log format: %v", ctx.String(logFormatFlag.Name))
|
||||
return fmt.Errorf("unknown log format: %v", ctx.String(LogFormatFlag.Name))
|
||||
}
|
||||
|
||||
glogger = log.NewGlogHandler(handler)
|
||||
|
|
|
|||
Loading…
Reference in a new issue