go-logging
go-logging copied to clipboard
format log message before sending it to write queue
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}
in async mode, this is not guaranteed.