go-logging icon indicating copy to clipboard operation
go-logging copied to clipboard

format log message before sending it to write queue

Open emptyhua opened this issue 7 years ago • 1 comments
trafficstars

package main

import (
	"github.com/ccding/go-logging/logging"
)

type Resp struct {
	Msg string
}

func main() {
	logger, _ := logging.SimpleLogger("main")

	resp := &Resp{"hello"}
	logger.Errorf("resp=%+v", resp)
	resp.Msg = "world"
	logger.Errorf("resp=%+v", resp)

	logger.Destroy()
}

output:

main [ ERROR]  2018-08-27 16:23:41.796996122 - resp=&{Msg:world}
main [ ERROR]  2018-08-27 16:23:41.797058713 - resp=&{Msg:world}

the first mesage shoud be resp=&{Msg:hello}

emptyhua avatar Aug 27 '18 08:08 emptyhua

in async mode, this is not guaranteed.

ccding avatar Aug 27 '18 19:08 ccding