From 60392e61c714ad16c9b292180e447dac8f28fd59 Mon Sep 17 00:00:00 2001 From: r Date: Sat, 9 Sep 2023 06:30:38 +0000 Subject: Disable access log by default Access logs aren't really useful during normal operation. Add a new flag -v to enable the verbose logging mode, which is still useful during the development. Also remove the log_file config because it's no longer useful. --- service/transport.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'service') diff --git a/service/transport.go b/service/transport.go index 5c6472c..dcf2990 100644 --- a/service/transport.go +++ b/service/transport.go @@ -23,7 +23,7 @@ const ( CSRF ) -func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { +func NewHandler(s *service, verbose bool, staticDir string) http.Handler { r := mux.NewRouter() writeError := func(c *client, err error, t int, retry bool) { @@ -48,10 +48,12 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { r: req, } - defer func(begin time.Time) { - logger.Printf("path=%s, err=%v, took=%v\n", - req.URL.Path, err, time.Since(begin)) - }(time.Now()) + if verbose { + defer func(begin time.Time) { + log.Printf("path=%s, err=%v, took=%v\n", + req.URL.Path, err, time.Since(begin)) + }(time.Now()) + } var ct string switch rt { -- cgit v1.2.3