2014-04-26 09:18:56 +00:00
|
|
|
package Log
|
|
|
|
|
2014-10-19 17:19:11 +00:00
|
|
|
import (
|
|
|
|
"github.com/SommerEngineering/Ocean/Log/Device"
|
|
|
|
)
|
2014-04-26 09:18:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Please do not call this function your self! This function allows Ocean to flush the logging at the shutting down case.
|
|
|
|
*/
|
|
|
|
func Flush() {
|
|
|
|
mutexChannel.Lock()
|
|
|
|
channelReady = false
|
|
|
|
close(entriesBuffer)
|
|
|
|
mutexChannel.Unlock()
|
|
|
|
|
2014-11-07 12:00:55 +00:00
|
|
|
<-schedulerExitSignal
|
2014-04-26 09:18:56 +00:00
|
|
|
|
|
|
|
mutexDeviceDelays.Lock()
|
|
|
|
dataArray := logEntryListToArray(deviceDelayBuffer)
|
|
|
|
deviceDelayBuffer.Init()
|
|
|
|
mutexDeviceDelays.Unlock()
|
|
|
|
|
|
|
|
mutexDevices.RLock()
|
|
|
|
for entry := devices.Front(); entry != nil; entry = entry.Next() {
|
|
|
|
dev := entry.Value.(Device.Device)
|
|
|
|
dev.Log(dataArray) // Want to wait to complete, therefore no new thread here
|
2014-11-07 12:00:55 +00:00
|
|
|
dev.Flush()
|
2014-04-26 09:18:56 +00:00
|
|
|
}
|
|
|
|
mutexDevices.RUnlock()
|
|
|
|
}
|