1
0

Added a flag for logging to stdout that if set overrides configuration.

This commit is contained in:
Alexander Andreev 2022-02-07 21:12:30 +04:00
parent d024138593
commit 53bf25364a
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -16,6 +16,7 @@ import (
)
var configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout")
func main() {
flag.Parse()
@ -42,19 +43,23 @@ func main() {
}
}
logErr, err := logging.NewLogger(config.Log.Error)
if *logToStdout {
config.Log.ToStdout = true
}
logErr, err := logging.NewLogger(config.Log.Error, config.Log.ToStdout)
if err != nil {
log.Fatalln("failed to open error logger:", err)
}
defer logErr.Close()
logUpload, err := logging.NewLogger(config.Log.Upload)
logUpload, err := logging.NewLogger(config.Log.Upload, config.Log.ToStdout)
if err != nil {
log.Fatalln("failed to open upload logger:", err)
}
defer logUpload.Close()
logDownload, err := logging.NewLogger(config.Log.Download)
logDownload, err := logging.NewLogger(config.Log.Download, config.Log.ToStdout)
if err != nil {
log.Fatalln("failed to open download logger:", err)
}