update go app

This commit is contained in:
durbok
2024-12-28 16:27:20 +01:00
parent 3c68b0b358
commit 12ec068339
4 changed files with 71 additions and 12 deletions

20
config/logger.go Normal file
View File

@@ -0,0 +1,20 @@
package config
import (
"log"
"os"
)
// InitializeLogger sets up logging to a file.
func InitializeLogger(logFileName string) {
// Open the log file for writing (create if it doesn't exist, append if it does)
file, err := os.OpenFile(logFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
log.Fatalf("Failed to open log file: %v", err)
}
// Set the output of the default logger to the file
log.SetOutput(file)
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
log.Println("Logging initialized")
}