Last Updated: February 25, 2016
·
724
· adnaan

Go: Line No. and File Name in Logs

I use this to log errors with more contextual information.
Just:

Llongfile // full file name and line number: /a/b/c/d.go:23

Lshortfile // final file name element and line number: d.go:23. overrides Llongfile

log.setFlags(log.Lshortfile)

Log Contstants