mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
log: move more instances of 'nil' to '<nil>'
This commit is contained in:
parent
49ef852aeb
commit
e89763002b
2 changed files with 6 additions and 6 deletions
|
|
@ -126,12 +126,12 @@ func (h *TerminalHandler) logfmt(buf *bytes.Buffer, r slog.Record, color int) {
|
||||||
// formatValue formats a value for serialization
|
// formatValue formats a value for serialization
|
||||||
func FormatLogfmtValue(value interface{}, term bool) (result string) {
|
func FormatLogfmtValue(value interface{}, term bool) (result string) {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return "nil"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
if v := reflect.ValueOf(value); v.Kind() == reflect.Ptr && v.IsNil() {
|
if v := reflect.ValueOf(value); v.Kind() == reflect.Ptr && v.IsNil() {
|
||||||
result = "nil"
|
result = "<nil>"
|
||||||
} else {
|
} else {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ func FormatLogfmtValue(value interface{}, term bool) (result string) {
|
||||||
// Big ints get consumed by the Stringer clause, so we need to handle
|
// Big ints get consumed by the Stringer clause, so we need to handle
|
||||||
// them earlier on.
|
// them earlier on.
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return "nil"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
return formatLogfmtBigInt(v)
|
return formatLogfmtBigInt(v)
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ func FormatLogfmtValue(value interface{}, term bool) (result string) {
|
||||||
// Uint256s get consumed by the Stringer clause, so we need to handle
|
// Uint256s get consumed by the Stringer clause, so we need to handle
|
||||||
// them earlier on.
|
// them earlier on.
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return "nil"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
return formatLogfmtUint256(v)
|
return formatLogfmtUint256(v)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,13 +188,13 @@ func builtinReplace(_ []string, attr slog.Attr) slog.Attr {
|
||||||
attr = slog.Any(attr.Key, v.Format(timeFormat))
|
attr = slog.Any(attr.Key, v.Format(timeFormat))
|
||||||
case *big.Int:
|
case *big.Int:
|
||||||
if v == nil {
|
if v == nil {
|
||||||
attr.Value = slog.StringValue("nil")
|
attr.Value = slog.StringValue("<nil>")
|
||||||
} else {
|
} else {
|
||||||
attr.Value = slog.StringValue(v.String())
|
attr.Value = slog.StringValue(v.String())
|
||||||
}
|
}
|
||||||
case *uint256.Int:
|
case *uint256.Int:
|
||||||
if v == nil {
|
if v == nil {
|
||||||
attr.Value = slog.StringValue("nil")
|
attr.Value = slog.StringValue("<nil>")
|
||||||
} else {
|
} else {
|
||||||
attr.Value = slog.StringValue(v.Dec())
|
attr.Value = slog.StringValue(v.Dec())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue