Change to error logging behaviour (stderr instead of stdout, by default).

This commit is contained in:
Solderpunk 2023-02-07 19:33:14 +01:00
parent 16bf8e0534
commit 443bfd4bbd
3 changed files with 8 additions and 7 deletions

View File

@ -217,10 +217,11 @@ examples of the appropriate syntax.
i.e. in the current wrorking directory). Note that all intermediate i.e. in the current wrorking directory). Note that all intermediate
directories must exist, Molly Brown won't create them for you. Set directories must exist, Molly Brown won't create them for you. Set
to `-` for logging to `stdout`. to `-` for logging to `stdout`.
* `ErrorLog`: Path to error log file (default value `error.log`, i.e. * `ErrorLog`: Path to error log file. If set to an empty string (the
in the current wrorking directory). Note that all intermediate default), Molly Brown will log errors to stderr (where they are
directories must exist, Molly Brown won't create them for you. Set easily captured by systemd or similar init systems). If set to a
to `-` for logging to `stdout`. file, note that all intermediate directories must exist, Molly Brown
won't create them for you.
* `GeminiExt`: Files with this extension will be served with a MIME * `GeminiExt`: Files with this extension will be served with a MIME
type of `text/gemini` (default value `gmi`). type of `text/gemini` (default value `gmi`).
* `MimeOverrides`: In this section of the config file, keys are path * `MimeOverrides`: In this section of the config file, keys are path

View File

@ -63,7 +63,7 @@ func getConfig(filename string) (Config, error) {
config.DefaultLang = "" config.DefaultLang = ""
config.DefaultEncoding = "" config.DefaultEncoding = ""
config.AccessLog = "access.log" config.AccessLog = "access.log"
config.ErrorLog = "error.log" config.ErrorLog = ""
config.TempRedirects = make(map[string]string) config.TempRedirects = make(map[string]string)
config.PermRedirects = make(map[string]string) config.PermRedirects = make(map[string]string)
config.CGIPaths = make([]string, 0) config.CGIPaths = make([]string, 0)

View File

@ -40,8 +40,8 @@ func main() {
// Open log files // Open log files
var errorLogFile *os.File var errorLogFile *os.File
if config.ErrorLog == "-" { if config.ErrorLog == "" {
errorLogFile = os.Stdout errorLogFile = os.Stderr
} else { } else {
errorLogFile, err = os.OpenFile(config.ErrorLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) errorLogFile, err = os.OpenFile(config.ErrorLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {