mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 01:48:15 +03:00
When logging structs, do log fields of type time.Time (timestamps)
The simplistic logging approach we've followed so far is to not log struct fields that are themselves structs, which time.Time is. So we skipped, but do log it now.
This commit is contained in:
parent
719dc2bee1
commit
5294a63c26
@ -393,6 +393,8 @@ func formatString(s string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
var typeTime = reflect.TypeFor[time.Time]()
|
||||
|
||||
func stringValue(iscid, nested bool, v any) string {
|
||||
// Handle some common types first.
|
||||
if v == nil {
|
||||
@ -478,7 +480,8 @@ func stringValue(iscid, nested bool, v any) string {
|
||||
if !t.Field(i).IsExported() {
|
||||
continue
|
||||
}
|
||||
if j == 0 && (fv.Kind() == reflect.Struct || fv.Kind() == reflect.Ptr || fv.Kind() == reflect.Interface) {
|
||||
// todo: decide on better approach about which fields to include while preventing recursion
|
||||
if j == 0 && (fv.Kind() == reflect.Struct || fv.Kind() == reflect.Ptr || fv.Kind() == reflect.Interface) && fv.Type() != typeTime {
|
||||
// Don't recurse.
|
||||
continue
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user