Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
8f012fce
Commit
8f012fce
authored
4 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
added new logger
parent
b1be2bf4
No related branches found
No related tags found
2 merge requests
!22
Resolve "Logging: Which way we go?"
,
!18
Develop
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
database/database.go
+5
-6
5 additions, 6 deletions
database/database.go
main.go
+3
-0
3 additions, 0 deletions
main.go
nucleus/controller.go
+1
-1
1 addition, 1 deletion
nucleus/controller.go
nucleus/nucleus-core.go
+12
-12
12 additions, 12 deletions
nucleus/nucleus-core.go
with
21 additions
and
19 deletions
database/database.go
+
5
−
6
View file @
8f012fce
package
database
package
database
import
(
import
(
"log"
"code.fbi.h-da.de/cocsn/gosdn/log"
"github.com/neo4j/neo4j-go-driver/neo4j"
"github.com/neo4j/neo4j-go-driver/neo4j"
)
)
...
@@ -74,7 +73,7 @@ func (d Database) StoreNodes(json string) {
...
@@ -74,7 +73,7 @@ func (d Database) StoreNodes(json string) {
logError
(
"failed storing Nodes into database"
,
err
)
logError
(
"failed storing Nodes into database"
,
err
)
log
.
Printf
(
"successfully added Nodes into database"
)
log
.
Info
(
"successfully added Nodes into database"
)
}
}
//StoreNodeEdgePoints stores the given node edge points (interfaces)
//StoreNodeEdgePoints stores the given node edge points (interfaces)
...
@@ -101,7 +100,7 @@ func (d Database) StoreNodeEdgePoints(json string) {
...
@@ -101,7 +100,7 @@ func (d Database) StoreNodeEdgePoints(json string) {
setNodeNodeEdgePointsRelation
(
session
)
setNodeNodeEdgePointsRelation
(
session
)
log
.
Printf
(
"successfully added NodeEdgePoints into database"
)
log
.
Info
(
"successfully added NodeEdgePoints into database"
)
}
}
...
@@ -121,12 +120,12 @@ func setNodeNodeEdgePointsRelation(session neo4j.Session) {
...
@@ -121,12 +120,12 @@ func setNodeNodeEdgePointsRelation(session neo4j.Session) {
logError
(
"failed storing NodeNodeEdgePointsRelation into database"
,
err
)
logError
(
"failed storing NodeNodeEdgePointsRelation into database"
,
err
)
log
.
Printf
(
"successfully stored NodeNodeEdgePointsRelation into database"
)
log
.
Info
(
"successfully stored NodeNodeEdgePointsRelation into database"
)
}
}
//logError logs error with custom and error message
//logError logs error with custom and error message
func
logError
(
message
string
,
err
error
)
{
func
logError
(
message
string
,
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"%v: %v"
,
message
,
err
)
log
.
Info
(
"%v: %v"
,
message
,
err
)
}
}
}
}
This diff is collapsed.
Click to expand it.
main.go
+
3
−
0
View file @
8f012fce
package
main
package
main
import
(
import
(
"code.fbi.h-da.de/cocsn/gosdn/log"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"flag"
"flag"
)
)
...
@@ -15,8 +16,10 @@ func main() {
...
@@ -15,8 +16,10 @@ func main() {
flag
.
Parse
()
flag
.
Parse
()
cliSocket
:=
*
cliListenAddr
+
":"
+
*
cliListenPort
cliSocket
:=
*
cliListenAddr
+
":"
+
*
cliListenPort
log
.
Loglevel
(
log
.
DEBUG
)
// hand off to cmd for further processing
// hand off to cmd for further processing
nucleus
.
StartUp
(
cliSocket
,
*
configFileName
)
nucleus
.
StartUp
(
cliSocket
,
*
configFileName
)
log
.
Info
(
"Startup completed"
)
nucleus
.
Run
()
nucleus
.
Run
()
// nothing to see here, please move on!
// nothing to see here, please move on!
...
...
This diff is collapsed.
Click to expand it.
nucleus/controller.go
+
1
−
1
View file @
8f012fce
...
@@ -2,10 +2,10 @@ package nucleus
...
@@ -2,10 +2,10 @@ package nucleus
import
(
import
(
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/log"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"code.fbi.h-da.de/cocsn/gosdn/restconf/client/ciena"
"code.fbi.h-da.de/cocsn/gosdn/restconf/client/ciena"
"github.com/BurntSushi/toml"
"github.com/BurntSushi/toml"
"log"
"os"
"os"
)
)
...
...
This diff is collapsed.
Click to expand it.
nucleus/nucleus-core.go
+
12
−
12
View file @
8f012fce
...
@@ -3,11 +3,11 @@ package nucleus
...
@@ -3,11 +3,11 @@ package nucleus
import
(
import
(
pb
"code.fbi.h-da.de/cocsn/gosdn/cliInterface"
pb
"code.fbi.h-da.de/cocsn/gosdn/cliInterface"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/log"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
"context"
"context"
_
"github.com/mattn/go-sqlite3"
_
"github.com/mattn/go-sqlite3"
"google.golang.org/grpc"
"google.golang.org/grpc"
"log"
"net"
"net"
"time"
"time"
)
)
...
@@ -20,31 +20,31 @@ type server struct {
...
@@ -20,31 +20,31 @@ type server struct {
// SayHello implements helloworld.GreeterServer
// SayHello implements helloworld.GreeterServer
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
log
.
Debug
(
"Received: %v"
,
in
.
GetName
())
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
()},
nil
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
()},
nil
}
}
func
(
s
*
server
)
Shutdown
(
ctx
context
.
Context
,
in
*
pb
.
ShutdownRequest
)
(
*
pb
.
ShutdownReply
,
error
)
{
func
(
s
*
server
)
Shutdown
(
ctx
context
.
Context
,
in
*
pb
.
ShutdownRequest
)
(
*
pb
.
ShutdownReply
,
error
)
{
log
.
Printf
(
"Received: %v"
,
in
.
GetName
())
log
.
Debug
(
"Received: %v"
,
in
.
GetName
())
isRunning
=
false
isRunning
=
false
return
&
pb
.
ShutdownReply
{
Message
:
"Shutdown "
+
in
.
GetName
()},
nil
return
&
pb
.
ShutdownReply
{
Message
:
"Shutdown "
+
in
.
GetName
()},
nil
}
}
func
getCLIGoing
(
core
*
Core
)
{
func
getCLIGoing
(
core
*
Core
)
{
log
.
Println
(
"Starting: GetCLIGoing"
)
log
.
Info
(
"Starting: GetCLIGoing"
)
// Boot-up the control interface for the cli
// Boot-up the control interface for the cli
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
f
(
"failed to listen: %v"
,
err
)
log
.
Fatal
(
"failed to listen: %v"
,
err
)
}
}
cliControlServer
:=
grpc
.
NewServer
()
cliControlServer
:=
grpc
.
NewServer
()
pb
.
RegisterGreeterServer
(
cliControlServer
,
&
server
{
core
:
core
})
pb
.
RegisterGreeterServer
(
cliControlServer
,
&
server
{
core
:
core
})
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
log
.
Fatal
f
(
"failed to serve: %v"
,
err
)
log
.
Fatal
(
"failed to serve: %v"
,
err
)
}
}
log
.
Println
(
"Started: GetCLIGoing"
)
log
.
Info
(
"Started: GetCLIGoing"
)
}
}
/*
/*
...
@@ -54,8 +54,8 @@ func getCLIGoing(core *Core) {
...
@@ -54,8 +54,8 @@ func getCLIGoing(core *Core) {
// Next-up: backend database.
// Next-up: backend database.
func
StartUp
(
socket
,
filename
string
)
{
func
StartUp
(
socket
,
filename
string
)
{
log
.
Println
(
"This is the network superintendent..."
)
log
.
Info
(
"This is the network superintendent..."
)
log
.
Println
(
"Starting my ducks"
)
log
.
Info
(
"Starting my ducks"
)
// Init the Core
// Init the Core
core
:=
Core
{
core
:=
Core
{
clients
:
make
(
map
[
string
]
interfaces
.
Client
,
0
),
clients
:
make
(
map
[
string
]
interfaces
.
Client
,
0
),
...
@@ -64,7 +64,7 @@ func StartUp(socket, filename string) {
...
@@ -64,7 +64,7 @@ func StartUp(socket, filename string) {
core
.
Init
(
socket
,
filename
)
core
.
Init
(
socket
,
filename
)
// Start the GRCP CLI
// Start the GRCP CLI
go
getCLIGoing
(
&
core
)
go
getCLIGoing
(
&
core
)
log
.
Println
(
"and ready for take off"
)
log
.
Info
(
"and ready for take off"
)
}
}
...
@@ -78,8 +78,8 @@ func Run() {
...
@@ -78,8 +78,8 @@ func Run() {
for
isRunning
{
for
isRunning
{
time
.
Sleep
(
10
*
time
.
Second
)
time
.
Sleep
(
10
*
time
.
Second
)
log
.
Println
(
"Still alive..."
)
log
.
Debug
(
"Still alive..."
)
}
}
log
.
Println
(
"Good bye....!"
)
log
.
Info
(
"Good bye....!"
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment