diff options
author | r <r@freesoftwareextremist.com> | 2023-09-09 06:30:38 +0000 |
---|---|---|
committer | r <r@freesoftwareextremist.com> | 2023-09-09 06:38:52 +0000 |
commit | 60392e61c714ad16c9b292180e447dac8f28fd59 (patch) | |
tree | e5bd64885e5054b0ce59e13854033454458c0b84 /service | |
parent | 8eec93e02861ff0d133d8ba5613e2dedbcee40a2 (diff) | |
download | bloat-60392e61c714ad16c9b292180e447dac8f28fd59.tar.gz bloat-60392e61c714ad16c9b292180e447dac8f28fd59.zip |
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.
Diffstat (limited to 'service')
-rw-r--r-- | service/transport.go | 12 |
1 files changed, 7 insertions, 5 deletions
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 { |