From 3be10b82d7ba6b4713386523bf1e352e71320a42 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Tue, 7 Feb 2023 19:59:43 +0100 Subject: [PATCH] Allow no access logging with empty string log file path. --- README.md | 3 ++- main.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a06a5dd..f5cdc33 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,8 @@ examples of the appropriate syntax. * `AccessLog`: Path to access log file (default value `access.log`, i.e. in the current wrorking directory). Note that all intermediate directories must exist, Molly Brown won't create them for you. Set - to `-` for logging to `stdout`. + to `-` for logging to `stdout`, or to an empty string to disable + access logging. * `ErrorLog`: Path to error log file. If set to an empty string (the default), Molly Brown will log errors to stderr (where they are easily captured by systemd or similar init systems). If set to a diff --git a/main.go b/main.go index 6725f14..03aaa36 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,10 @@ func main() { errorLog := log.New(errorLogFile, "", log.Ldate | log.Ltime) var accessLogFile *os.File + // TODO: Find a more elegant/portable way to disable logging + if config.AccessLog == "" { + config.AccessLog = "/dev/null" + } if config.AccessLog == "-" { accessLogFile = os.Stdout } else {