From 0480e066a3f1ae97dbab8fcb6303589eb0fa724c Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 23 Jan 2023 22:15:16 -0700 Subject: logging library up to top level --- contrib/log/log.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 contrib/log/log.go (limited to 'contrib/log') 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) - } - } -} -- cgit v1.2.3