func (r *responseRecorder) Status() int {
	return r.status
}
Status returns the HTTP status code of the response.
package logging
import (
	"io"
	"net/http"
	"time"
)
var DefaultFormatter = defaultFormatter{}
type TimeProviderFunc func() time.Time
type HandlerFactory struct {
	TimeProvider TimeProviderFunc
	Formatter    Formatter
}
func (f *HandlerFactory) LoggingHandler(log io.Writer, h http.Handler) http.Handler {
	return &loggingHandler{
		Handler: h,
		log:     log,
		now:     f.TimeProvider,
		format:  f.Formatter,
	}
}
var DefaultLoggingHandlerFactory = HandlerFactory{
	TimeProvider: time.Now,
	Formatter:    DefaultFormatter,
}
func Handler(log io.Writer, h http.Handler) http.Handler {
	return DefaultLoggingHandlerFactory.LoggingHandler(log, h)
}
type loggingHandler struct {
	http.Handler
	format Formatter
	log    io.Writer
	now    TimeProviderFunc
}
func (h *loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	wrec := &responseRecorder{ResponseWriter: w}
	defer func(startedAt time.Time) {
		e := &AccessEntry{
			StartedAt:  startedAt,
			FinishedAt: h.now(),
			Request:    req,
			Response:   wrec,
		}
		h.log.Write([]byte(h.format.Format(e)))
	}(h.now())
	h.Handler.ServeHTTP(wrec, req)
}
type AccessEntry struct {
	Request    *http.Request
	Response   ResponseRecorder
	StartedAt  time.Time
	FinishedAt time.Time
}
type ResponseRecorder interface {
	http.ResponseWriter
	Status() int
	Size() int
}
type responseRecorder struct {
	http.ResponseWriter
	status int
	size   int
}
func (r *responseRecorder) Header() http.Header {
	return r.ResponseWriter.Header()
}
func (r *responseRecorder) Write(data []byte) (int, error) {
	n, err := r.ResponseWriter.Write(data)
	if r.status == 0 {
		r.status = http.StatusOK
	}
	r.size += n
	return n, err
}
func (r *responseRecorder) WriteHeader(status int) {
	r.ResponseWriter.WriteHeader(status)
	r.status = status
}