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:
parent
b50066ef5d
commit
f33f7b5c29
@ -1,6 +1,8 @@
|
|||||||
package Configuration
|
package Configuration
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Configuration/Meta"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Configuration/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read the whole configuration and enable Ocean to get the configuration database.
|
Read the whole configuration and enable Ocean to get the configuration database.
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package Configuration
|
package Configuration
|
||||||
|
|
||||||
import "encoding/json"
|
import (
|
||||||
import "os"
|
"encoding/json"
|
||||||
import "path/filepath"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
func readConfiguration() {
|
func readConfiguration() {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Configuration
|
package Configuration
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Configuration/Meta"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Configuration/Meta"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
filename = "configuration.json" // Where is the configuration located?
|
filename = "configuration.json" // Where is the configuration located?
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo/bson"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
func checkConfiguration() {
|
func checkConfiguration() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `Check now the configuration database.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `Check now the configuration database.`)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Configuration"
|
"github.com/SommerEngineering/Ocean/Configuration"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "labix.org/v2/mgo/bson"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function reads the current configuration value.
|
This function reads the current configuration value.
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Do not use this type by your own! It is a Ocean internal type to provide a shutdown function for the configuration database.
|
Do not use this type by your own! It is a Ocean internal type to provide a shutdown function for the configuration database.
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Configuration/Meta"
|
"github.com/SommerEngineering/Ocean/Configuration/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
session *mgo.Session = nil
|
session *mgo.Session = nil
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ConfigurationDB
|
package ConfigurationDB
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "labix.org/v2/mgo/bson"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function writes the configuration value.
|
This function writes the configuration value.
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package CustomerDB
|
package CustomerDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get the database instance of the MGo Mongo driver.
|
Get the database instance of the MGo Mongo driver.
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package CustomerDB
|
package CustomerDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package CustomerDB
|
package CustomerDB
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Please do not use this type. It is an internal type of Ocean to provide a shutdown function!
|
Please do not use this type. It is an internal type of Ocean to provide a shutdown function!
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package CustomerDB
|
package CustomerDB
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mainSession *mgo.Session = nil
|
mainSession *mgo.Session = nil
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "reflect"
|
"fmt"
|
||||||
import "strconv"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func Data2Message(target interface{}, data map[string][]string) (channel, command string, obj interface{}) {
|
func Data2Message(target interface{}, data map[string][]string) (channel, command string, obj interface{}) {
|
||||||
if data == nil || len(data) == 0 {
|
if data == nil || len(data) == 0 {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
This is the "[I]nter Data [C]enter and Appli[c]ation [C]ommunication"
|
This is the "[I]nter-[C]omponent [C]ommunication [C]hannel"
|
||||||
*/
|
*/
|
||||||
package ICCC
|
package ICCC
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "net/http"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func ICCCHandler(response http.ResponseWriter, request *http.Request) {
|
func ICCCHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
if errParse := request.ParseForm(); errParse != nil {
|
if errParse := request.ParseForm(); errParse != nil {
|
||||||
|
10
ICCC/Init.go
10
ICCC/Init.go
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "container/list"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"container/list"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of ICCC.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of ICCC.`)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
func initDB() {
|
func initDB() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of the ICCC collections.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of the ICCC collections.`)
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "time"
|
"fmt"
|
||||||
import "labix.org/v2/mgo/bson"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func InitCacheNow() {
|
func InitCacheNow() {
|
||||||
startCacheTimerLock.Lock()
|
startCacheTimerLock.Lock()
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "reflect"
|
"fmt"
|
||||||
import "strconv"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func message2Data(channel, command string, message interface{}) (data map[string][]string) {
|
func message2Data(channel, command string, message interface{}) (data map[string][]string) {
|
||||||
data = make(map[string][]string)
|
data = make(map[string][]string)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "labix.org/v2/mgo/bson"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
func register2Database(channel, command string) {
|
func register2Database(channel, command string) {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Register this ICCC command in to the database.`, `channel=`+channel, `command=`+command)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Register this ICCC command in to the database.`, `channel=`+channel, `command=`+command)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "labix.org/v2/mgo/bson"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
func registerHost2Database() {
|
func registerHost2Database() {
|
||||||
host := Scheme.Host{}
|
host := Scheme.Host{}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"fmt"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func Registrar(channel, command string, callback func(data map[string][]string)) {
|
func Registrar(channel, command string, callback func(data map[string][]string)) {
|
||||||
listenersLock.Lock()
|
listenersLock.Lock()
|
||||||
|
14
ICCC/Send.go
14
ICCC/Send.go
@ -1,11 +1,13 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "net/url"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
func sendMessage(listener Scheme.Listener, data map[string][]string) {
|
func sendMessage(listener Scheme.Listener, data map[string][]string) {
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "labix.org/v2/mgo/bson"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Please do not use this type. It is an internal type of Ocean to provide a shutdown function!
|
Please do not use this type. It is an internal type of Ocean to provide a shutdown function!
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
import "container/list"
|
"container/list"
|
||||||
import "labix.org/v2/mgo"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"gopkg.in/mgo.v2"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ChannelSYSTEM string = `System`
|
ChannelSYSTEM string = `System`
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func WriteMessage2All(channel, command string, message interface{}) {
|
func WriteMessage2All(channel, command string, message interface{}) {
|
||||||
cacheListenerDatabaseLock.RLock()
|
cacheListenerDatabaseLock.RLock()
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ICCC
|
package ICCC
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
)
|
||||||
|
|
||||||
func WriteMessage2Any(channel, command string, message interface{}) {
|
func WriteMessage2Any(channel, command string, message interface{}) {
|
||||||
cacheListenerDatabaseLock.RLock()
|
cacheListenerDatabaseLock.RLock()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Log
|
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,
|
Registering the logging devices. Normally, it is not necessary to call this function. To enable or disable a logging device,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "container/list"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
"container/list"
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func logEntryListToArray(data *list.List) (result []Meta.Entry) {
|
func logEntryListToArray(data *list.List) (result []Meta.Entry) {
|
||||||
count := data.Len()
|
count := data.Len()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Device
|
package Device
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
type Device interface {
|
type Device interface {
|
||||||
Log(logEntries []Meta.Entry)
|
Log(logEntries []Meta.Entry)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package DeviceConsole
|
package DeviceConsole
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
)
|
||||||
|
|
||||||
func ActivateLoggingDevice() {
|
func ActivateLoggingDevice() {
|
||||||
Log.AddLoggingDevice(Console{})
|
Log.AddLoggingDevice(Console{})
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package DeviceConsole
|
package DeviceConsole
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
"fmt"
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
type Console struct {
|
type Console struct {
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
)
|
||||||
|
|
||||||
func ActivateLoggingDevice() {
|
func ActivateLoggingDevice() {
|
||||||
Log.AddLoggingDevice(Database{})
|
Log.AddLoggingDevice(Database{})
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "strconv"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
func initDatabase() {
|
func initDatabase() {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// Case: The cache is full
|
// Case: The cache is full
|
||||||
func cacheFull() {
|
func cacheFull() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type LogDBEntry struct {
|
type LogDBEntry struct {
|
||||||
TimeUTC time.Time `bson:"TimeUTC"`
|
TimeUTC time.Time `bson:"TimeUTC"`
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
import "labix.org/v2/mgo"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"gopkg.in/mgo.v2"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
senderName LM.Sender = `System::Logger::Database`
|
senderName LM.Sender = `System::Logger::Database`
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package DeviceDatabase
|
package DeviceDatabase
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func write2Cache(entries []Meta.Entry) {
|
func write2Cache(entries []Meta.Entry) {
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Device"
|
"github.com/SommerEngineering/Ocean/Log/Device"
|
||||||
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func deviceDelay(newEntry Meta.Entry) {
|
func deviceDelay(newEntry Meta.Entry) {
|
||||||
defer checkDeviceDelaySize()
|
defer checkDeviceDelaySize()
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Device"
|
"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.
|
Please do not call this function your self! This function allows Ocean to flush the logging at the shutting down case.
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "strings"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func writeToChannel(logEntry Meta.Entry) {
|
func writeToChannel(logEntry Meta.Entry) {
|
||||||
select {
|
select {
|
||||||
|
18
Log/Init.go
18
Log/Init.go
@ -1,13 +1,15 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
import "strconv"
|
"container/list"
|
||||||
import "container/list"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "sync"
|
"io/ioutil"
|
||||||
import "path/filepath"
|
"os"
|
||||||
import "os"
|
"path/filepath"
|
||||||
import "io/ioutil"
|
"strconv"
|
||||||
import "strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
func readProjectName() {
|
func readProjectName() {
|
||||||
if currentDir, dirError := os.Getwd(); dirError != nil {
|
if currentDir, dirError := os.Getwd(); dirError != nil {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Meta
|
package Meta
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Entry struct {
|
type Entry struct {
|
||||||
Project string
|
Project string
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package Meta
|
package Meta
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "time"
|
"fmt"
|
||||||
import "strconv"
|
"strconv"
|
||||||
import "strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func (entry Entry) Format() (result string) {
|
func (entry Entry) Format() (result string) {
|
||||||
|
|
||||||
@ -23,18 +25,18 @@ func (entry Entry) Format() (result string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageDescription := entry.MessageDescription
|
messageDescription := entry.MessageDescription
|
||||||
messageDescription = strings.Replace(messageDescription, `\n`, ` `, -1)
|
messageDescription = strings.Replace(messageDescription, "\n", ` `, -1)
|
||||||
messageDescription = strings.Replace(messageDescription, `\t`, ` `, -1)
|
messageDescription = strings.Replace(messageDescription, "\t", ` `, -1)
|
||||||
messageDescription = strings.Replace(messageDescription, `\r`, ` `, -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)
|
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 {
|
for _, param := range entry.Parameters {
|
||||||
|
|
||||||
paramText := param
|
paramText := param
|
||||||
paramText = strings.Replace(paramText, `\n`, ` `, -1)
|
paramText = strings.Replace(paramText, "\n", ` `, -1)
|
||||||
paramText = strings.Replace(paramText, `\t`, ` `, -1)
|
paramText = strings.Replace(paramText, "\t", ` `, -1)
|
||||||
paramText = strings.Replace(paramText, `\r`, ` `, -1)
|
paramText = strings.Replace(paramText, "\r", ` `, -1)
|
||||||
|
|
||||||
result = fmt.Sprintf(`%s %s [■]`, result, paramText)
|
result = fmt.Sprintf(`%s %s [■]`, result, paramText)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
import "time"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// Note: The scheduler is the consumer for the logging channel!
|
// Note: The scheduler is the consumer for the logging channel!
|
||||||
func scheduler(logBuffer chan Meta.Entry) {
|
func scheduler(logBuffer chan Meta.Entry) {
|
||||||
|
10
Log/Timer.go
10
Log/Timer.go
@ -1,9 +1,11 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Device"
|
"github.com/SommerEngineering/Ocean/Log/Device"
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func initTimer() {
|
func initTimer() {
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Log
|
package Log
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
import "container/list"
|
"container/list"
|
||||||
import "sync"
|
"github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
entriesBuffer chan Meta.Entry = nil
|
entriesBuffer chan Meta.Entry = nil
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package MimeTypes
|
package MimeTypes
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type MimeType struct {
|
type MimeType struct {
|
||||||
MimeType string
|
MimeType string
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package MimeTypes
|
package MimeTypes
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func Write2HTTP(response http.ResponseWriter, mime MimeType) {
|
func Write2HTTP(response http.ResponseWriter, mime MimeType) {
|
||||||
response.Header().Add(`Content-Type`, mime.MimeType)
|
response.Header().Add(`Content-Type`, mime.MimeType)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "net/url"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "strconv"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"net/http"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func GetNextInt64(name string) (result int64) {
|
func GetNextInt64(name string) (result int64) {
|
||||||
result = badNumber64
|
result = badNumber64
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "net/http"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func HandlerGetNext(response http.ResponseWriter, request *http.Request) {
|
func HandlerGetNext(response http.ResponseWriter, request *http.Request) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
import "strconv"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Init the number generator.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Init the number generator.`)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "labix.org/v2/mgo"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"gopkg.in/mgo.v2"
|
||||||
|
)
|
||||||
|
|
||||||
func initDB() {
|
func initDB() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of number generator collection.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of number generator collection.`)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "labix.org/v2/mgo/bson"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func producer(name string) {
|
func producer(name string) {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `The NumGen producer is now starting.`, `name=`+name)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `The NumGen producer is now starting.`, `name=`+name)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
)
|
||||||
|
|
||||||
func requestChannel4Name(name string) (result chan int64) {
|
func requestChannel4Name(name string) (result chan int64) {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
type ShutdownFunction struct {
|
type ShutdownFunction struct {
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package NumGen
|
package NumGen
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
import "labix.org/v2/mgo"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"gopkg.in/mgo.v2"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
correctPassword string = ``
|
correctPassword string = ``
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package Robots
|
package Robots
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "net/http"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func HandlerRobots(response http.ResponseWriter, request *http.Request) {
|
func HandlerRobots(response http.ResponseWriter, request *http.Request) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Robots
|
package Robots
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Init the robots component.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Init the robots component.`)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Robots
|
package Robots
|
||||||
|
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
senderName LM.Sender = `System::Robots`
|
senderName LM.Sender = `System::Robots`
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Shutdown
|
package Shutdown
|
||||||
|
|
||||||
import "container/list"
|
import (
|
||||||
import "os/signal"
|
"container/list"
|
||||||
import "os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
shutdownHandlers = list.New()
|
shutdownHandlers = list.New()
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Shutdown
|
package Shutdown
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
type ShutdownHandler interface {
|
type ShutdownHandler interface {
|
||||||
Shutdown()
|
Shutdown()
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Shutdown
|
package Shutdown
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
import "container/list"
|
"container/list"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
shutdownSignal chan os.Signal = make(chan os.Signal)
|
shutdownSignal chan os.Signal = make(chan os.Signal)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package StaticFiles
|
package StaticFiles
|
||||||
|
|
||||||
import "io/ioutil"
|
import (
|
||||||
import "bytes"
|
"archive/zip"
|
||||||
import "archive/zip"
|
"bytes"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
func FindAndReadFile(filename string) (result []byte) {
|
func FindAndReadFile(filename string) (result []byte) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package StaticFiles
|
package StaticFiles
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "strings"
|
"fmt"
|
||||||
import "net/http"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/MimeTypes"
|
"github.com/SommerEngineering/Ocean/MimeTypes"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func HandlerStaticFiles(response http.ResponseWriter, request *http.Request) {
|
func HandlerStaticFiles(response http.ResponseWriter, request *http.Request) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package StaticFiles
|
package StaticFiles
|
||||||
|
|
||||||
import "io/ioutil"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Starting now the static files component.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Starting now the static files component.`)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package StaticFiles
|
package StaticFiles
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func HandlerMapStaticFiles2Root(response http.ResponseWriter, request *http.Request) {
|
func HandlerMapStaticFiles2Root(response http.ResponseWriter, request *http.Request) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package StaticFiles
|
package StaticFiles
|
||||||
|
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
senderName LM.Sender = `System::StaticFiles`
|
senderName LM.Sender = `System::StaticFiles`
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/ICCC"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func icccSystemStart(data map[string][]string) {
|
func icccSystemStart(data map[string][]string) {
|
||||||
_, _, obj := ICCC.Data2Message(&ICCCStartUpMessage{}, data)
|
_, _, obj := ICCC.Data2Message(&ICCCStartUpMessage{}, data)
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "runtime"
|
"fmt"
|
||||||
import "strconv"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/ICCC"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/NumGen"
|
"github.com/SommerEngineering/Ocean/NumGen"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func initSystem() {
|
func initSystem() {
|
||||||
|
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/WebContent"
|
"github.com/SommerEngineering/Ocean/ICCC"
|
||||||
import "github.com/SommerEngineering/Ocean/StaticFiles"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/NumGen"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Robots"
|
"github.com/SommerEngineering/Ocean/NumGen"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/Robots"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/StaticFiles"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/WebContent"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func InitHandlers() {
|
func InitHandlers() {
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import "github.com/SommerEngineering/Ocean/Log/DeviceConsole"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Log/DeviceDatabase"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log/DeviceConsole"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Log/DeviceDatabase"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
func initLoggingDevices() {
|
func initLoggingDevices() {
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
"github.com/SommerEngineering/Ocean/ICCC"
|
||||||
import "github.com/SommerEngineering/Ocean/ICCC"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func StartAndBlockForever() {
|
func StartAndBlockForever() {
|
||||||
ipAddressPort := Tools.LocalIPAddressAndPort()
|
ipAddressPort := Tools.LocalIPAddressAndPort()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
senderName LM.Sender = `System::System`
|
senderName LM.Sender = `System::System`
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package Templates
|
package Templates
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "bytes"
|
"archive/zip"
|
||||||
import "html/template"
|
"bytes"
|
||||||
import "io/ioutil"
|
"fmt"
|
||||||
import "archive/zip"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Tools"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"html/template"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Starting the template engine.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Starting the template engine.`)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package Templates
|
package Templates
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/MimeTypes"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/MimeTypes"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func ProcessHTML(templateName string, response http.ResponseWriter, data interface{}) {
|
func ProcessHTML(templateName string, response http.ResponseWriter, data interface{}) {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Templates
|
package Templates
|
||||||
|
|
||||||
import "html/template"
|
import (
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"html/template"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
templates *template.Template = nil
|
templates *template.Template = nil
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package Tools
|
package Tools
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func FormatTime(t1 time.Time) (result string) {
|
func FormatTime(t1 time.Time) (result string) {
|
||||||
var year int = t1.Year()
|
var year int = t1.Year()
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package Tools
|
package Tools
|
||||||
|
|
||||||
import "net"
|
import (
|
||||||
import "strings"
|
"net"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func ReadAllIPAddresses4ThisHost() (addresses4Host []string) {
|
func ReadAllIPAddresses4ThisHost() (addresses4Host []string) {
|
||||||
addresses4Host = ipAddresses
|
addresses4Host = ipAddresses
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package Tools
|
package Tools
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
import "time"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "math/rand"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"math/rand"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Get this hostname:
|
// Get this hostname:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Tools
|
package Tools
|
||||||
|
|
||||||
import "math/rand"
|
import (
|
||||||
|
"math/rand"
|
||||||
|
)
|
||||||
|
|
||||||
func RandomInteger(max int) (rnd int) {
|
func RandomInteger(max int) (rnd int) {
|
||||||
rnd = rand.Intn(max)
|
rnd = rand.Intn(max)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package Tools
|
package Tools
|
||||||
|
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
senderName LM.Sender = `System::Tools`
|
senderName LM.Sender = `System::Tools`
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package WebContent
|
package WebContent
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
import "archive/zip"
|
"archive/zip"
|
||||||
import "io/ioutil"
|
"bytes"
|
||||||
import "bytes"
|
"errors"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
func GetContent(path string) (content []byte, err error) {
|
func GetContent(path string) (content []byte, err error) {
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package WebContent
|
package WebContent
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "strings"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Shutdown"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func HandlerDeliverFramework(response http.ResponseWriter, request *http.Request) {
|
func HandlerDeliverFramework(response http.ResponseWriter, request *http.Request) {
|
||||||
if Shutdown.IsDown() {
|
if Shutdown.IsDown() {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package WebContent
|
package WebContent
|
||||||
|
|
||||||
import "io/ioutil"
|
import (
|
||||||
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
import "github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package WebContent
|
package WebContent
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
import "bytes"
|
"bytes"
|
||||||
import "errors"
|
"errors"
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "github.com/SommerEngineering/Ocean/MimeTypes"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
import "github.com/SommerEngineering/Ocean/Log"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
"github.com/SommerEngineering/Ocean/MimeTypes"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func SendContent(response http.ResponseWriter, path string) (err error) {
|
func SendContent(response http.ResponseWriter, path string) (err error) {
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package WebContent
|
package WebContent
|
||||||
|
|
||||||
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
import (
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
isInit = false
|
isInit = false
|
||||||
|
2
history.dat
Normal file
2
history.dat
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
3507|121819|2014.09.17 18:52:28:598
|
||||||
|
3685|121093|2014.10.19 17:10:51:188
|
Loading…
Reference in New Issue
Block a user