diff --git a/main.go b/main.go index 7efe1dd1..ddd25d5f 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,9 @@ import ( "net/http" "os" "os/signal" + "path" "regexp" + "runtime" "syscall" "time" @@ -83,8 +85,11 @@ func main() { log.SetLevel(log.DebugLevel) } - if logFormat == "json" { - log.SetFormatter(&log.JSONFormatter{}) + switch logFormat { + case "json": + log.SetFormatter(&log.JSONFormatter{CallerPrettyfier: prettifyCaller}) + default: + log.SetFormatter(&log.TextFormatter{CallerPrettyfier: prettifyCaller}) } log.SetReportCaller(logCaller) @@ -270,6 +275,11 @@ func serveMetrics() { } } +func prettifyCaller(f *runtime.Frame) (string, string) { + _, filename := path.Split(f.File) + return "", fmt.Sprintf("%s:%d", filename, f.Line) +} + var adminPage = `