Allow no access logging with empty string log file path.

This commit is contained in:
Solderpunk 2023-02-07 19:59:43 +01:00
parent 443bfd4bbd
commit 3be10b82d7
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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 {