From 8a21dad6031c1b4493b5623a0768aaca13d90be1 Mon Sep 17 00:00:00 2001 From: James Park-Watt Date: Sun, 27 Oct 2024 00:36:35 +0100 Subject: [PATCH] Add 'log-requests' option to disable request logging (#199) --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c98f8bd..dab811f 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ var ( cfg struct { Customize string `flag:"customize" default:"" description:"Customize-File to load"` Listen string `flag:"listen" default:":3000" description:"IP/Port to listen on"` + LogRequests bool `flag:"log-requests" default:"true" description:"Enable request logging"` LogLevel string `flag:"log-level" default:"info" description:"Set log level (debug, info, warning, error)"` SecretExpiry int64 `flag:"secret-expiry" default:"0" description:"Maximum expiry of the stored secrets in seconds"` StorageType string `flag:"storage-type" default:"mem" description:"Storage to use for putting secrets to" validate:"nonzero"` @@ -138,7 +139,9 @@ func main() { var hdl http.Handler = r hdl = http_helpers.GzipHandler(hdl) - hdl = http_helpers.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger()) + if cfg.LogRequests { + hdl = http_helpers.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger()) + } server := &http.Server{ Addr: cfg.Listen,