Added a multi-writer so that log messages go to both the console and log file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-09-03 10:51:25 -04:00
parent 602ddb1a00
commit 674327e0cf

View File

@ -1,6 +1,7 @@
package config
import (
"io"
"log"
"os"
@ -20,10 +21,12 @@ func InitLogging() *os.File {
log.Fatalf("Error opening log file: %v", err)
os.Exit(1)
}
// set logging to file handle
log.SetOutput(fileHandle)
}
// create a MultiWriter instance so we can write to both console AND file
mw := io.MultiWriter(os.Stdout, fileHandle)
// set our multiwriter object as the output for logging
log.SetOutput(mw)
return fileHandle
}