mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/geth: fix fileout-test by avoiding formatter-bug
This commit is contained in:
parent
b75f045714
commit
6de84c363f
2 changed files with 9 additions and 15 deletions
|
|
@ -149,18 +149,7 @@ func TestFileOut(t *testing.T) {
|
|||
path = fmt.Sprintf("%s/test_file_out-%d", os.TempDir(), rand.Int63())
|
||||
)
|
||||
t.Cleanup(func() { os.Remove(path) })
|
||||
/*
|
||||
If terminal/logfmt format is used, then this test fails -- apparently the file-, or stream-, or
|
||||
multiplexhandler somehow treats records with duplicate keys differently, adding an extra space
|
||||
on the log output between the two keys.
|
||||
Using the `json` format cheats and gets around this, since json cannot represent duplicate keys.
|
||||
|
||||
logging_test.go:153: have vs want:
|
||||
"repeated-key foo=once foo=twice\nINFO [10-19|14:42:23.554] log "
|
||||
"repeated-key foo=once foo=twice\nINFO [10-19|14:42:23.554] log"
|
||||
logging_test.go:154: file content wrong
|
||||
*/
|
||||
if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "--log.format=json", "logtest"); err != nil {
|
||||
if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "logtest"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if have, err = os.ReadFile(path); err != nil {
|
||||
|
|
|
|||
|
|
@ -86,10 +86,15 @@ func logTest(ctx *cli.Context) error {
|
|||
{ // Miscellaneous json-quirks
|
||||
// This will check if the json output uses strings or json-booleans to represent bool values
|
||||
log.Info("boolean", "true", true, "false", false)
|
||||
// Handling of duplicate keys ?
|
||||
log.Info("repeated-key", "foo", "once", "foo", "twice")
|
||||
// Handling of duplicate keys.
|
||||
// This is actually ill-handled by the current handler: the format.go
|
||||
// uses a global 'fieldPadding' map and mixes up the two keys. If 'alpha'
|
||||
// is shorter than beta, it sometimes causes erroneous padding -- and what's more
|
||||
// it causes _different_ padding in multi-handler context, e.g. both file-
|
||||
// and console output, making the two mismatch.
|
||||
log.Info("repeated-key", "foo", "alpha", "foo", "beta")
|
||||
}
|
||||
{ //
|
||||
{ // loglevels
|
||||
log.Debug("log at level debug")
|
||||
log.Trace("log at level trace")
|
||||
log.Info("log at level info")
|
||||
|
|
|
|||
Loading…
Reference in a new issue