2014-04-26 09:18:56 +00:00
package Log
2014-10-19 17:19:11 +00:00
import (
"container/list"
"github.com/SommerEngineering/Ocean/Log/Meta"
"strconv"
"sync"
)
2014-04-26 09:18:56 +00:00
2015-06-17 15:44:52 +00:00
// Init the logging package.
2014-04-26 09:18:56 +00:00
func init ( ) {
2015-06-17 15:44:52 +00:00
// Read the project name:
2014-04-26 09:18:56 +00:00
readProjectName ( )
2015-06-17 15:44:52 +00:00
// Create the mutexe:
2014-04-26 09:18:56 +00:00
mutexDeviceDelays = sync . Mutex { }
mutexPreChannelBuffer = sync . Mutex { }
mutexChannel = sync . RWMutex { }
2015-06-17 15:44:52 +00:00
// Create buffers:
2014-04-26 09:18:56 +00:00
preChannelBuffer = list . New ( )
deviceDelayBuffer = list . New ( )
2015-06-17 15:44:52 +00:00
// Create the device list:
2014-04-26 09:18:56 +00:00
devices = list . New ( )
2015-06-17 15:44:52 +00:00
// Channel to exit the scheduler:
2014-11-07 12:00:55 +00:00
schedulerExitSignal = make ( chan bool )
2014-04-26 09:18:56 +00:00
initTimer ( )
initCode ( )
}
func initCode ( ) {
2015-06-17 15:44:52 +00:00
// Creates the buffer for logging entries:
2014-04-26 09:18:56 +00:00
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:
2014-04-26 09:18:56 +00:00
go scheduler ( entriesBuffer )
}