diff options
Diffstat (limited to 'contrib/log')
-rw-r--r-- | contrib/log/log.go | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/contrib/log/log.go b/contrib/log/log.go deleted file mode 100644 index 0060f4e..0000000 --- a/contrib/log/log.go +++ /dev/null @@ -1,35 +0,0 @@ -package log - -import ( - "context" - "io" - "time" - - kitlog "github.com/go-kit/log" - - "tildegit.org/tjp/gus" -) - -func Requests(out io.Writer, logger kitlog.Logger) gus.Middleware { - if logger == nil { - logger = kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(out)) - } - - return func(next gus.Handler) gus.Handler { - return func(ctx context.Context, r *gus.Request) (resp *gus.Response) { - start := time.Now() - defer func() { - end := time.Now() - logger.Log( - "msg", "request", - "ts", end, - "dur", end.Sub(start), - "url", r.URL, - "status", resp.Status, - ) - }() - - return next(ctx, r) - } - } -} |