// WithAccessLog is a middleware that logs all access requests performed on the // sub handler using github.com/corestoreio/csfw/net/ctxlog and // github.com/rs/xstats stored in context. func WithAccessLog() Middleware { return func(h Handler) Handler { return HandlerFunc(func(ctx context.Context, w http.ResponseWriter, r *http.Request) error { // Time request reqStart := time.Now() // Sniff the status and content size for logging lw := mutil.WrapWriter(w) err := h.ServeHTTPContext(ctx, lw, r) // Compute request duration reqDur := time.Since(reqStart) // Get request status status := ResponseStatus(ctx, lw.Status()) // Log request stats sts := xstats.FromContext(ctx) tags := []string{ "status:" + status, "status_code:" + strconv.Itoa(lw.Status()), } sts.Timing("request_time", reqDur, tags...) sts.Histogram("request_size", float64(lw.BytesWritten()), tags...) ctxlog.FromContext(ctx).Info("request", "error", utils.Errors(err), "method", r.Method, "uri", r.URL.String(), "type", "access", "status", status, "status_code", lw.Status(), "duration", reqDur.Seconds(), "size", lw.BytesWritten(), "remote_addr", httputils.GetRemoteAddr(r).String(), "user_agent", r.Header.Get("User-Agent"), "referer", r.Header.Get("Referer"), ) return err }) } }
// Error returns an error string func (s *Service) Error() string { return utils.Errors(s.lastErrors...) }
func (a arg) Error() string { return utils.Errors(a.lastErrors...) }
// Error implements the error interface. Returns a string where each error has // been separated by a line break. func (dm *Daemon) Error() string { return utils.Errors(dm.lastErrs...) }
// Error implements the error interface. Returns a string where each error has // been separated by a line break. func (g *Group) Error() string { return utils.Errors(g.lastErrors...) }
// Error implements the error interface. Returns a string where each error has // been separated by a line break. func (w *Website) Error() string { return utils.Errors(w.lastErrors...) }