From dda53db017c8a649ef6f2631c915ce626b66d440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Wed, 13 Jun 2018 08:35:14 +0200 Subject: [PATCH] log response changes --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index afabc17..841373b 100644 --- a/main.go +++ b/main.go @@ -95,7 +95,7 @@ func (l *Logger) LogRequest(req *http.Request, userid string) { } else { b.WriteString(string(body)) } - b.WriteString("\n\n") + b.WriteString("\n") msg := b.String() @@ -109,14 +109,16 @@ func (l *Logger) LogRequest(req *http.Request, userid string) { } } -func (l *Logger) LogResponse(w http.ResponseWriter, duration time.Duration) { +func (l *Logger) LogResponse(w http.ResponseWriter, req *http.Request, duration time.Duration) { if l.outputFile != nil { var b strings.Builder b.WriteString("Response:\n") + fmt.Fprintf(&b, "%s %s\n", req.Method, req.RequestURI) for k, v := range w.Header() { - b.WriteString(fmt.Sprintf("%s: %s\n", k, v)) + fmt.Fprintf(&b, "%s: %s\n", k, v) } - b.WriteString(fmt.Sprintf("\nCompleted in: %v\n", duration)) + fmt.Fprintf(&b, "\nCompleted in: %v\n", duration) + b.WriteString("==============================================================\n\n") msg := b.String() l.mu.Lock() -- 1.8.1.2