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()