You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

logger.go 404B

9 yıl önce
1234567891011121314151617
  1. package middleware
  2. import (
  3. "net/http"
  4. "time"
  5. "github.com/sirupsen/logrus"
  6. )
  7. // Logger renders the simple HTTP accesses logs for the upcoming http.Handler.
  8. func Logger(next http.Handler) http.Handler {
  9. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  10. start := time.Now()
  11. next.ServeHTTP(w, r)
  12. logrus.Debugf("%s - %s (%v)", r.Method, r.URL.Path, time.Since(start))
  13. })
  14. }