Parse pointer struct when log
m1zzx2 opened this issue · comments
m1zzx2 commented
should we have some method, can parse pointer struct when log somemsg
package main
import "github.com/sirupsen/logrus"
type Msg struct {
msgStr string
Data *Data
}
type Data struct {
dataStr string
}
func main() {
Msg := Msg{msgStr: "msgstr", Data: &Data{dataStr: "datastr"}}
logrus.Infof("msg :%+v", Msg)
}
It should output
INFO[0000] msg :{msgStr:msgstr Data:0xc000096320}
I want to output
INFO[0000] msg :{msgStr:msgstr Data:{dataStr:datastr}}
github-actions commented
This issue is stale because it has been open for 30 days with no activity.
David Bariod commented
To be displayed correctly your struct must implement the fmt.Stringer
interface.
func (d Data) String() string {
return d.dataStr
}
github-actions commented
This issue is stale because it has been open for 30 days with no activity.
github-actions commented
This issue was closed because it has been inactive for 14 days since being marked as stale.