mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix fmt.Stringer values in json handler
This commit is contained in:
parent
e411480a43
commit
31dcb3daa8
1 changed files with 5 additions and 1 deletions
|
|
@ -213,7 +213,11 @@ func builtinReplace(_ []string, attr slog.Attr, logfmt bool) slog.Attr {
|
||||||
attr.Value = slog.StringValue(v.Dec())
|
attr.Value = slog.StringValue(v.Dec())
|
||||||
}
|
}
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
attr.Value = slog.StringValue(v.String())
|
if v == nil || (reflect.ValueOf(v).Kind() == reflect.Pointer && reflect.ValueOf(v).IsNil()) {
|
||||||
|
attr.Value = slog.StringValue("<nil>")
|
||||||
|
} else {
|
||||||
|
attr.Value = slog.StringValue(v.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return attr
|
return attr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue