f33f7b5c29
+ Refactored all imports + Fixed a bug for the logging regarding removing \n \t \r + Updated to current MGO release + Changed the name of ICCC
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package Log
|
|
|
|
import (
|
|
"container/list"
|
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strings"
|
|
"sync"
|
|
)
|
|
|
|
func readProjectName() {
|
|
if currentDir, dirError := os.Getwd(); dirError != nil {
|
|
panic(`Can not read the current working directory and therefore can not read the project name!`)
|
|
} else {
|
|
filename := filepath.Join(currentDir, `project.name`)
|
|
if _, errFile := os.Stat(filename); errFile != nil {
|
|
if os.IsNotExist(errFile) {
|
|
panic(`Can not read the project name file 'project.name': File not found!`)
|
|
} else {
|
|
panic(`Can not read the project name file 'project.name': ` + errFile.Error())
|
|
}
|
|
}
|
|
|
|
if projectNameBytes, errRead := ioutil.ReadFile(filename); errRead != nil {
|
|
panic(`Can not read the project name file 'project.name': ` + errRead.Error())
|
|
} else {
|
|
projectName = string(projectNameBytes)
|
|
projectName = strings.TrimSpace(projectName)
|
|
}
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
readProjectName()
|
|
mutexDeviceDelays = sync.Mutex{}
|
|
mutexPreChannelBuffer = sync.Mutex{}
|
|
mutexChannel = sync.RWMutex{}
|
|
preChannelBuffer = list.New()
|
|
deviceDelayBuffer = list.New()
|
|
devices = list.New()
|
|
|
|
initTimer()
|
|
initCode()
|
|
}
|
|
|
|
func initCode() {
|
|
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)))
|
|
go scheduler(entriesBuffer)
|
|
}
|