Commit dda53db017c8a649ef6f2631c915ce626b66d440
1 parent
cccb4b47c0
Exists in
master
log response changes
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
main.go
... | ... | @@ -95,7 +95,7 @@ func (l *Logger) LogRequest(req *http.Request, userid string) { |
95 | 95 | } else { |
96 | 96 | b.WriteString(string(body)) |
97 | 97 | } |
98 | - b.WriteString("\n\n") | |
98 | + b.WriteString("\n") | |
99 | 99 | |
100 | 100 | msg := b.String() |
101 | 101 | |
... | ... | @@ -109,14 +109,16 @@ func (l *Logger) LogRequest(req *http.Request, userid string) { |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | -func (l *Logger) LogResponse(w http.ResponseWriter, duration time.Duration) { | |
112 | +func (l *Logger) LogResponse(w http.ResponseWriter, req *http.Request, duration time.Duration) { | |
113 | 113 | if l.outputFile != nil { |
114 | 114 | var b strings.Builder |
115 | 115 | b.WriteString("Response:\n") |
116 | + fmt.Fprintf(&b, "%s %s\n", req.Method, req.RequestURI) | |
116 | 117 | for k, v := range w.Header() { |
117 | - b.WriteString(fmt.Sprintf("%s: %s\n", k, v)) | |
118 | + fmt.Fprintf(&b, "%s: %s\n", k, v) | |
118 | 119 | } |
119 | - b.WriteString(fmt.Sprintf("\nCompleted in: %v\n", duration)) | |
120 | + fmt.Fprintf(&b, "\nCompleted in: %v\n", duration) | |
121 | + b.WriteString("==============================================================\n\n") | |
120 | 122 | msg := b.String() |
121 | 123 | |
122 | 124 | l.mu.Lock() | ... | ... |