feat(Logger): ConsoleLogger filepath now changeable from code
This commit is contained in:
@@ -7,8 +7,16 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (lgr *FileLoggerImpl) SetLogFilePath(path string) {
|
||||||
|
lgr.initfilepath = path
|
||||||
|
}
|
||||||
|
|
||||||
func (lgr *FileLoggerImpl) init() {
|
func (lgr *FileLoggerImpl) init() {
|
||||||
lgr.filepath = "./log"
|
if lgr.initfilepath == "" {
|
||||||
|
lgr.filepath = "./log"
|
||||||
|
} else {
|
||||||
|
lgr.filepath = lgr.initfilepath
|
||||||
|
}
|
||||||
lgr.messages = make(chan string, Logbuffersize)
|
lgr.messages = make(chan string, Logbuffersize)
|
||||||
envfp, envexist := os.LookupEnv("LOGFILE_GO_LOGGER")
|
envfp, envexist := os.LookupEnv("LOGFILE_GO_LOGGER")
|
||||||
if envexist {
|
if envexist {
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ type ConsoleLoggerImpl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FileLoggerImpl struct {
|
type FileLoggerImpl struct {
|
||||||
messages chan string
|
messages chan string
|
||||||
mutex *sync.Mutex
|
mutex *sync.Mutex
|
||||||
logFile *os.File
|
logFile *os.File
|
||||||
filepath string
|
filepath string
|
||||||
|
initfilepath string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user