Golang microseconds in a log packet

Golang has a standard log package. Is there a way to output mircoseconds to its output?

The standard code puts a rather useless second precision timestamp:

log.Println("Starting app on", APP_PORT)

2015/07/29 19:28:32 Starting app on :9090

      

+3


source to share


1 answer


Modify the log flags to add microseconds. Available flags: http://golang.org/pkg/log/#pkg-constants



log.SetFlags(log.LstdFlags | log.Lmicroseconds)
log.Print("Hello, playground")
// 2009/11/10 23:00:00.000000 Hello, playground

      

+12


source







All Articles