Ocean/Log/Init.go

43 lines
1018 B
Go
Raw Normal View History

package Log
import (
"container/list"
"github.com/SommerEngineering/Ocean/Log/Meta"
"strconv"
"sync"
)
2015-06-17 15:44:52 +00:00
// Init the logging package.
func init() {
2015-06-17 15:44:52 +00:00
// Read the project name:
readProjectName()
2015-06-17 15:44:52 +00:00
// Create the mutexe:
mutexDeviceDelays = sync.Mutex{}
mutexPreChannelBuffer = sync.Mutex{}
mutexChannel = sync.RWMutex{}
2015-06-17 15:44:52 +00:00
// Create buffers:
preChannelBuffer = list.New()
deviceDelayBuffer = list.New()
2015-06-17 15:44:52 +00:00
// Create the device list:
devices = list.New()
2015-06-17 15:44:52 +00:00
// Channel to exit the scheduler:
schedulerExitSignal = make(chan bool)
initTimer()
initCode()
}
func initCode() {
2015-06-17 15:44:52 +00:00
// Creates the buffer for logging entries:
entriesBuffer = make(chan Meta.Entry, logBufferSize)
LogShort(senderName, Meta.CategorySYSTEM, Meta.LevelINFO, `Starting`, `The logger is now starting.`, `logBufferSize=`+strconv.Itoa(int(logBufferSize)), `logBufferTimeoutSeconds=`+strconv.Itoa(int(logBufferTimeoutSeconds)))
2015-06-17 15:44:52 +00:00
// Start the scheduler as new thread:
go scheduler(entriesBuffer)
}