fix(Logger)!: consoleLogger and FileLogger StartLogger now automatically start a goroutine when called

This commit is contained in:
2024-10-27 02:29:09 +02:00
parent eb041fd18c
commit 88b3d9fa34
2 changed files with 23 additions and 19 deletions

View File

@@ -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)
}
}()
})
}

View File

@@ -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()