Reverse the coupling of module log and config #1606

Merged
konrad merged 9 commits from HoffmannP/api:main into main 2023-10-03 09:28:34 +00:00
Showing only changes of commit 5af348dbe1 - Show all commits

View File

@ -88,9 +88,8 @@ func GetLogWriter(logfmt string, logfile string) (writer io.Writer) {
writer = os.Stdout // Set the default case to prevent nil pointer panics
switch logfmt {
case "file":
err := os.Mkdir(logPath, 0744)
if err != nil && !os.IsExist(err) {
Fatalf("Could not create log folder: %s", err.Error())
if err := os.MkdirAll(logPath, 0744); err != nil {
Fatalf("Could not create log path: %s", err.Error())
}
fullLogFilePath := logPath + "/" + logfile + ".log"
f, err := os.OpenFile(fullLogFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)