diff --git a/logger/filelogger.go b/logger/filelogger.go index da9b3db..5f023ab 100644 --- a/logger/filelogger.go +++ b/logger/filelogger.go @@ -7,8 +7,16 @@ import ( "time" ) +func (lgr *FileLoggerImpl) SetLogFilePath(path string) { + lgr.initfilepath = path +} + func (lgr *FileLoggerImpl) init() { - lgr.filepath = "./log" + if lgr.initfilepath == "" { + lgr.filepath = "./log" + } else { + lgr.filepath = lgr.initfilepath + } lgr.messages = make(chan string, Logbuffersize) envfp, envexist := os.LookupEnv("LOGFILE_GO_LOGGER") if envexist { diff --git a/logger/types.go b/logger/types.go index ace5cfa..aaaa3a4 100644 --- a/logger/types.go +++ b/logger/types.go @@ -14,8 +14,9 @@ type ConsoleLoggerImpl struct { } type FileLoggerImpl struct { - messages chan string - mutex *sync.Mutex - logFile *os.File - filepath string + messages chan string + mutex *sync.Mutex + logFile *os.File + filepath string + initfilepath string }