package logger

import (
	"log"
	"os"
	"sync"
)

var once sync.Once

func InitializeLogger(filePath string) error {
	var err error
	once.Do(func() {
		logFile, e := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
		if e != nil {
			err = e
			return
		}
		log.SetOutput(logFile)
		log.SetFlags(log.LstdFlags | log.Lshortfile)
	})
	return err
}
