fix(Logger)!: consoleLogger and FileLogger StartLogger now automatically start a goroutine when called
This commit is contained in:
@@ -12,9 +12,11 @@ func (lgr *ConsoleLoggerImpl) init() {
|
||||
func (logger *ConsoleLoggerImpl) StartLogger() {
|
||||
fmt.Println("Starting Logger")
|
||||
loggerlogonce.Do(func() {
|
||||
go func() {
|
||||
for msg := range logger.messages {
|
||||
fmt.Print(msg)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ func (lgr *FileLoggerImpl) init() {
|
||||
func (logger *FileLoggerImpl) StartLogger() {
|
||||
fmt.Println("Starting FileLogger")
|
||||
loggerlogonce.Do(func() {
|
||||
go func() {
|
||||
for msg := range logger.messages {
|
||||
|
||||
logger.mutex.Lock()
|
||||
@@ -59,6 +60,7 @@ func (logger *FileLoggerImpl) StartLogger() {
|
||||
}
|
||||
logger.mutex.Unlock()
|
||||
}
|
||||
}()
|
||||
})
|
||||
// Technically we should do this but this will never run
|
||||
// logger.mutex.Lock()
|
||||
|
||||
Reference in New Issue
Block a user