| Conditions | 2 |
| Total Lines | 18 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package internalhttp |
||
| 24 | func (a *MiddlewareLogger) loggingMiddleware(next http.Handler) http.Handler { |
||
| 25 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
||
| 26 | sw := &statusWriter{ResponseWriter: w} |
||
| 27 | |||
| 28 | l := r.Context().Value(KeyLoggerID).(Logger) |
||
| 29 | start := time.Now() |
||
| 30 | |||
| 31 | next.ServeHTTP(sw, r) |
||
| 32 | |||
| 33 | l.Debugf("%s [%s] %s %s %s %d %s %s %s\n", |
||
| 34 | r.RemoteAddr, |
||
| 35 | start.Format("02/Jan/2006:15:04:05 -0700"), |
||
| 36 | r.Method, |
||
| 37 | r.RequestURI, |
||
| 38 | sw.status, |
||
| 39 | http.StatusText(sw.status), |
||
| 40 | time.Since(start).String(), |
||
| 41 | r.Header.Get("User-Agent"), |
||
| 42 | ) |
||
| 52 |