1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
package middleware
import (
"github.com/alexliesenfeld/health"
"log"
"net/http"
"time"
)
// BasicLogger is a basic logger that is mostly used to showcase this library.
func BasicLogger() health.Middleware {
return func(next health.MiddlewareFunc) health.MiddlewareFunc {
return func(r *http.Request) health.CheckerResult {
now := time.Now()
result := next(r)
log.Printf("processed health check request in %f seconds (result: %s)",
time.Now().Sub(now).Seconds(), result.Status)
return result
}
}
}
|