Refactoring, Bugfix & Updates

+ Refactored all imports
+ Fixed a bug for the logging regarding removing \n \t \r
+ Updated to current MGO release
+ Changed the name of ICCC
This commit is contained in:
Thorsten Sommer committed 2014-10-19 19:19:11 +02:00
1 parent b50066ef5d
commit f33f7b5c29
91 files changed
+496 -316

No files matched your search

+3 -1
View File
@@ -1,6 +1,8 @@
package Log
import "github.com/SommerEngineering/Ocean/Log/Device"
import (
"github.com/SommerEngineering/Ocean/Log/Device"
)
/*
Registering the logging devices. Normally, it is not necessary to call this function. To enable or disable a logging device,
+4 -2
View File
@@ -1,7 +1,9 @@
package Log
import "container/list"
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"container/list"
"github.com/SommerEngineering/Ocean/Log/Meta"
)
func logEntryListToArray(data *list.List) (result []Meta.Entry) {
count := data.Len()
+3 -1
View File
@@ -1,6 +1,8 @@
package Device
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"github.com/SommerEngineering/Ocean/Log/Meta"
)
type Device interface {
Log(logEntries []Meta.Entry)
+3 -1
View File
@@ -1,6 +1,8 @@
package DeviceConsole
import "github.com/SommerEngineering/Ocean/Log"
import (
"github.com/SommerEngineering/Ocean/Log"
)
func ActivateLoggingDevice() {
Log.AddLoggingDevice(Console{})
+4 -2
View File
@@ -1,7 +1,9 @@
package DeviceConsole
import "fmt"
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"fmt"
"github.com/SommerEngineering/Ocean/Log/Meta"
)
type Console struct {
}
+3 -1
View File
@@ -1,6 +1,8 @@
package DeviceDatabase
import "github.com/SommerEngineering/Ocean/Log"
import (
"github.com/SommerEngineering/Ocean/Log"
)
func ActivateLoggingDevice() {
Log.AddLoggingDevice(Database{})
+7 -5
View File
@@ -1,10 +1,12 @@
package DeviceDatabase
import "strconv"
import "fmt"
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"fmt"
"github.com/SommerEngineering/Ocean/ConfigurationDB"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"strconv"
)
func init() {
+6 -4
View File
@@ -1,9 +1,11 @@
package DeviceDatabase
import "labix.org/v2/mgo"
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"github.com/SommerEngineering/Ocean/ConfigurationDB"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"gopkg.in/mgo.v2"
)
func initDatabase() {
+4 -2
View File
@@ -1,7 +1,9 @@
package DeviceDatabase
import "time"
import "github.com/SommerEngineering/Ocean/Shutdown"
import (
"github.com/SommerEngineering/Ocean/Shutdown"
"time"
)
// Case: The cache is full
func cacheFull() {
+3 -1
View File
@@ -1,6 +1,8 @@
package DeviceDatabase
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"github.com/SommerEngineering/Ocean/Log/Meta"
)
type Database struct {
}
+3 -1
View File
@@ -1,6 +1,8 @@
package DeviceDatabase
import "time"
import (
"time"
)
type LogDBEntry struct {
TimeUTC time.Time `bson:"TimeUTC"`
+5 -3
View File
@@ -1,8 +1,10 @@
package DeviceDatabase
import "sync"
import "labix.org/v2/mgo"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
import (
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"gopkg.in/mgo.v2"
"sync"
)
var (
senderName LM.Sender = `System::Logger::Database`
+3 -1
View File
@@ -1,6 +1,8 @@
package DeviceDatabase
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"github.com/SommerEngineering/Ocean/Log/Meta"
)
func write2Cache(entries []Meta.Entry) {
for _, entry := range entries {
+4 -2
View File
@@ -1,7 +1,9 @@
package Log
import "github.com/SommerEngineering/Ocean/Log/Meta"
import "github.com/SommerEngineering/Ocean/Log/Device"
import (
"github.com/SommerEngineering/Ocean/Log/Device"
"github.com/SommerEngineering/Ocean/Log/Meta"
)
func deviceDelay(newEntry Meta.Entry) {
defer checkDeviceDelaySize()
+4 -2
View File
@@ -1,7 +1,9 @@
package Log
import "time"
import "github.com/SommerEngineering/Ocean/Log/Device"
import (
"github.com/SommerEngineering/Ocean/Log/Device"
"time"
)
/*
Please do not call this function your self! This function allows Ocean to flush the logging at the shutting down case.
+6 -4
View File
@@ -1,9 +1,11 @@
package Log
import "time"
import "fmt"
import "strings"
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"fmt"
"github.com/SommerEngineering/Ocean/Log/Meta"
"strings"
"time"
)
func writeToChannel(logEntry Meta.Entry) {
select {
+10 -8
View File
@@ -1,13 +1,15 @@
package Log
import "github.com/SommerEngineering/Ocean/Log/Meta"
import "strconv"
import "container/list"
import "sync"
import "path/filepath"
import "os"
import "io/ioutil"
import "strings"
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 {
+3 -1
View File
@@ -1,6 +1,8 @@
package Meta
import "time"
import (
"time"
)
type Entry struct {
Project string
+12 -10
View File
@@ -1,9 +1,11 @@
package Meta
import "fmt"
import "time"
import "strconv"
import "strings"
import (
"fmt"
"strconv"
"strings"
"time"
)
func (entry Entry) Format() (result string) {
@@ -23,18 +25,18 @@ func (entry Entry) Format() (result string) {
}
messageDescription := entry.MessageDescription
messageDescription = strings.Replace(messageDescription, `\n`, ` `, -1)
messageDescription = strings.Replace(messageDescription, `\t`, ` `, -1)
messageDescription = strings.Replace(messageDescription, `\r`, ` `, -1)
messageDescription = strings.Replace(messageDescription, "\n", ` `, -1)
messageDescription = strings.Replace(messageDescription, "\t", ` `, -1)
messageDescription = strings.Replace(messageDescription, "\r", ` `, -1)
result = fmt.Sprintf(` [■] P:%10s [■] %s [■] %10s [■] %11s [■] %10s [■] %10s [■] sender: %-40s [■] name: %-26s [■] %s [■]`, entry.Project[:lenProject], formatTime(entry.Time), FormatCategory(entry.Category), FormatLevel(entry.Level), FormatSeverity(entry.Severity), FormatImpact(entry.Impact), entry.Sender[:lenSender], entry.MessageName[:lenMessageName], messageDescription)
for _, param := range entry.Parameters {
paramText := param
paramText = strings.Replace(paramText, `\n`, ` `, -1)
paramText = strings.Replace(paramText, `\t`, ` `, -1)
paramText = strings.Replace(paramText, `\r`, ` `, -1)
paramText = strings.Replace(paramText, "\n", ` `, -1)
paramText = strings.Replace(paramText, "\t", ` `, -1)
paramText = strings.Replace(paramText, "\r", ` `, -1)
result = fmt.Sprintf(`%s %s [■]`, result, paramText)
}
+4 -2
View File
@@ -1,7 +1,9 @@
package Log
import "github.com/SommerEngineering/Ocean/Log/Meta"
import "time"
import (
"github.com/SommerEngineering/Ocean/Log/Meta"
"time"
)
// Note: The scheduler is the consumer for the logging channel!
func scheduler(logBuffer chan Meta.Entry) {
+6 -4
View File
@@ -1,9 +1,11 @@
package Log
import "time"
import "fmt"
import "github.com/SommerEngineering/Ocean/Log/Device"
import "github.com/SommerEngineering/Ocean/Log/Meta"
import (
"fmt"
"github.com/SommerEngineering/Ocean/Log/Device"
"github.com/SommerEngineering/Ocean/Log/Meta"
"time"
)
func initTimer() {
+5 -3
View File
@@ -1,8 +1,10 @@
package Log
import "github.com/SommerEngineering/Ocean/Log/Meta"
import "container/list"
import "sync"
import (
"container/list"
"github.com/SommerEngineering/Ocean/Log/Meta"
"sync"
)
var (
entriesBuffer chan Meta.Entry = nil