Skip to content
Snippets Groups Projects
Commit d7962911 authored by capossele's avatar capossele
Browse files

:loud_sound: improves debug logs

parent ce132d2d
No related branches found
No related tags found
No related merge requests found
package client package client
import ( import (
"encoding/hex"
"net" "net"
"time" "time"
...@@ -57,19 +58,19 @@ func Run(plugin *node.Plugin) { ...@@ -57,19 +58,19 @@ func Run(plugin *node.Plugin) {
func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers {
return &EventDispatchers{ return &EventDispatchers{
AddNode: func(nodeId []byte) { AddNode: func(nodeId []byte) {
log.Debugw("AddNode", "nodeId", nodeId) log.Debugw("AddNode", "nodeId", hex.EncodeToString(nodeId))
_, _ = conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal()) _, _ = conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal())
}, },
RemoveNode: func(nodeId []byte) { RemoveNode: func(nodeId []byte) {
log.Debugw("RemoveNode", "nodeId", nodeId) log.Debugw("RemoveNode", "nodeId", hex.EncodeToString(nodeId))
_, _ = conn.Write((&removenode.Packet{NodeId: nodeId}).Marshal()) _, _ = conn.Write((&removenode.Packet{NodeId: nodeId}).Marshal())
}, },
ConnectNodes: func(sourceId []byte, targetId []byte) { ConnectNodes: func(sourceId []byte, targetId []byte) {
log.Debugw("ConnectNodes", "sourceId", sourceId, "targetId", targetId) log.Debugw("ConnectNodes", "sourceId", hex.EncodeToString(sourceId), "targetId", hex.EncodeToString(targetId))
_, _ = conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) _, _ = conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal())
}, },
DisconnectNodes: func(sourceId []byte, targetId []byte) { DisconnectNodes: func(sourceId []byte, targetId []byte) {
log.Debugw("DisconnectNodes", "sourceId", sourceId, "targetId", targetId) log.Debugw("DisconnectNodes", "sourceId", hex.EncodeToString(sourceId), "targetId", hex.EncodeToString(targetId))
_, _ = conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) _, _ = conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal())
}, },
} }
......
...@@ -16,6 +16,7 @@ var lock sync.Mutex ...@@ -16,6 +16,7 @@ var lock sync.Mutex
func Configure(plugin *node.Plugin) { func Configure(plugin *node.Plugin) {
server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) { server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) {
plugin.Node.Logger.Debugw("AddNode", "nodeID", nodeId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -25,6 +26,7 @@ func Configure(plugin *node.Plugin) { ...@@ -25,6 +26,7 @@ func Configure(plugin *node.Plugin) {
})) }))
server.Events.RemoveNode.Attach(events.NewClosure(func(nodeId string) { server.Events.RemoveNode.Attach(events.NewClosure(func(nodeId string) {
plugin.Node.Logger.Debugw("RemoveNode", "nodeID", nodeId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -32,6 +34,7 @@ func Configure(plugin *node.Plugin) { ...@@ -32,6 +34,7 @@ func Configure(plugin *node.Plugin) {
})) }))
server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) { server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) {
plugin.Node.Logger.Debugw("NodeOnline", "nodeID", nodeId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -39,6 +42,7 @@ func Configure(plugin *node.Plugin) { ...@@ -39,6 +42,7 @@ func Configure(plugin *node.Plugin) {
})) }))
server.Events.NodeOffline.Attach(events.NewClosure(func(nodeId string) { server.Events.NodeOffline.Attach(events.NewClosure(func(nodeId string) {
plugin.Node.Logger.Debugw("NodeOffline", "nodeID", nodeId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -46,6 +50,7 @@ func Configure(plugin *node.Plugin) { ...@@ -46,6 +50,7 @@ func Configure(plugin *node.Plugin) {
})) }))
server.Events.ConnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { server.Events.ConnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) {
plugin.Node.Logger.Debugw("ConnectNodes", "sourceID", sourceId, "targetId", targetId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -59,6 +64,7 @@ func Configure(plugin *node.Plugin) { ...@@ -59,6 +64,7 @@ func Configure(plugin *node.Plugin) {
})) }))
server.Events.DisconnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { server.Events.DisconnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) {
plugin.Node.Logger.Debugw("DisconnectNodes", "sourceID", sourceId, "targetId", targetId)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment