sirupsen / logrus

Structured, pluggable logging for Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse pointer struct when log

m1zzx2 opened this issue · comments

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}}       

This issue is stale because it has been open for 30 days with no activity.

To be displayed correctly your struct must implement the fmt.Stringer interface.

func (d Data) String() string {
	return d.dataStr
}

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.