From 619469059c82bcea85f06de4bf903b136f454891 Mon Sep 17 00:00:00 2001 From: Maximilian Date: Tue, 1 Nov 2022 16:30:54 -0500 Subject: [PATCH] Create logs folder if it doesn't already exist --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 416586f..ce752ea 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,12 @@ func main() { // Load config file to application app.Config = config.LoadConfig() - // Set log file + // Create logs directory if it doesn't exist + if _, err := os.Stat("logs"); os.IsNotExist(err) { + os.Mkdir("logs", 0755) + } + + // Create log file and set output file, _ := os.Create("logs/log-" + time.Now().String() + ".log") log.SetOutput(file)