Suppress log messages

This commit is contained in:
Asim Aslam 2019-11-03 16:12:17 +00:00
parent d3151f1f0f
commit 45cd14c4b7
3 changed files with 13 additions and 15 deletions

View File

@ -309,7 +309,7 @@ func (n *network) acceptNetConn(l tunnel.Listener, recv chan *message) {
func (n *network) updatePeerLinks(peerAddr string, linkId string) error { func (n *network) updatePeerLinks(peerAddr string, linkId string) error {
n.Lock() n.Lock()
defer n.Unlock() defer n.Unlock()
log.Debugf("Network looking up link %s in the peer links", linkId) log.Tracef("Network looking up link %s in the peer links", linkId)
// lookup the peer link // lookup the peer link
var peerLink tunnel.Link var peerLink tunnel.Link
for _, link := range n.tunnel.Links() { for _, link := range n.tunnel.Links() {
@ -322,7 +322,7 @@ func (n *network) updatePeerLinks(peerAddr string, linkId string) error {
return ErrPeerLinkNotFound return ErrPeerLinkNotFound
} }
// if the peerLink is found in the returned links update peerLinks // if the peerLink is found in the returned links update peerLinks
log.Debugf("Network updating peer links for peer %s", peerAddr) log.Tracef("Network updating peer links for peer %s", peerAddr)
// add peerLink to the peerLinks map // add peerLink to the peerLinks map
if link, ok := n.peerLinks[peerAddr]; ok { if link, ok := n.peerLinks[peerAddr]; ok {
// if the existing has better Length then the new, replace it // if the existing has better Length then the new, replace it
@ -369,7 +369,7 @@ func (n *network) processNetChan(listener tunnel.Listener) {
lastSeen: now, lastSeen: now,
} }
// update peer links // update peer links
log.Debugf("Network updating peer link %s for peer: %s", m.session.Link(), pbNetConnect.Node.Address) log.Tracef("Network updating peer link %s for peer: %s", m.session.Link(), pbNetConnect.Node.Address)
if err := n.updatePeerLinks(pbNetConnect.Node.Address, m.session.Link()); err != nil { if err := n.updatePeerLinks(pbNetConnect.Node.Address, m.session.Link()); err != nil {
log.Debugf("Network failed updating peer links: %s", err) log.Debugf("Network failed updating peer links: %s", err)
} }
@ -412,7 +412,7 @@ func (n *network) processNetChan(listener tunnel.Listener) {
lastSeen: now, lastSeen: now,
} }
// update peer links // update peer links
log.Debugf("Network updating peer link %s for peer: %s", m.session.Link(), pbNetPeer.Node.Address) log.Tracef("Network updating peer link %s for peer: %s", m.session.Link(), pbNetPeer.Node.Address)
if err := n.updatePeerLinks(pbNetPeer.Node.Address, m.session.Link()); err != nil { if err := n.updatePeerLinks(pbNetPeer.Node.Address, m.session.Link()); err != nil {
log.Debugf("Network failed updating peer links: %s", err) log.Debugf("Network failed updating peer links: %s", err)
} }
@ -439,7 +439,7 @@ func (n *network) processNetChan(listener tunnel.Listener) {
// NOTE: we don't unpack MaxDepth toplogy // NOTE: we don't unpack MaxDepth toplogy
peer = UnpackPeerTopology(pbNetPeer, now, MaxDepth-1) peer = UnpackPeerTopology(pbNetPeer, now, MaxDepth-1)
log.Debugf("Network updating topology of node: %s", n.node.id) log.Tracef("Network updating topology of node: %s", n.node.id)
if err := n.node.UpdatePeer(peer); err != nil { if err := n.node.UpdatePeer(peer); err != nil {
log.Debugf("Network failed to update peers: %v", err) log.Debugf("Network failed to update peers: %v", err)
} }
@ -701,16 +701,14 @@ func (n *network) getRouteMetric(router string, gateway string, link string) int
defer n.RUnlock() defer n.RUnlock()
if link == "local" && gateway == "" { if link == "local" && gateway == "" {
log.Debugf("Network link: %s, gateway: blank", link)
return 1 return 1
} }
if link == "local" && gateway != "" { if link == "local" && gateway != "" {
log.Debugf("Network link: %s, gateway: %s", link, gateway)
return 2 return 2
} }
log.Debugf("Network looking up %s link to gateway: %s", link, gateway) log.Tracef("Network looking up %s link to gateway: %s", link, gateway)
if link, ok := n.peerLinks[gateway]; ok { if link, ok := n.peerLinks[gateway]; ok {
// maka sure delay is non-zero // maka sure delay is non-zero
delay := link.Delay() delay := link.Delay()
@ -725,7 +723,7 @@ func (n *network) getRouteMetric(router string, gateway string, link string) int
log.Debugf("Link length is 0 %v %v", link, link.Length()) log.Debugf("Link length is 0 %v %v", link, link.Length())
length = 10e9 length = 10e9
} }
log.Debugf("Network calculated metric %v delay %v length %v distance %v", (delay*length*int64(hops))/10e6, delay, length, hops) log.Tracef("Network calculated metric %v delay %v length %v distance %v", (delay*length*int64(hops))/10e6, delay, length, hops)
return (delay * length * int64(hops)) / 10e6 return (delay * length * int64(hops)) / 10e6
} }
@ -789,7 +787,7 @@ func (n *network) processCtrlChan(listener tunnel.Listener) {
// calculate route metric and add to the advertised metric // calculate route metric and add to the advertised metric
// we need to make sure we do not overflow math.MaxInt64 // we need to make sure we do not overflow math.MaxInt64
metric := n.getRouteMetric(event.Route.Router, event.Route.Gateway, event.Route.Link) metric := n.getRouteMetric(event.Route.Router, event.Route.Gateway, event.Route.Link)
log.Debugf("Network metric for router %s and gateway %s: %v", event.Route.Router, event.Route.Gateway, metric) log.Tracef("Network metric for router %s and gateway %s: %v", event.Route.Router, event.Route.Gateway, metric)
// check we don't overflow max int 64 // check we don't overflow max int 64
if d := route.Metric + metric; d > math.MaxInt64 || d <= 0 { if d := route.Metric + metric; d > math.MaxInt64 || d <= 0 {
@ -810,7 +808,7 @@ func (n *network) processCtrlChan(listener tunnel.Listener) {
} }
// if no events are eligible for processing continue // if no events are eligible for processing continue
if len(events) == 0 { if len(events) == 0 {
log.Debugf("Network no events to be processed by router: %s", n.options.Id) log.Tracef("Network no events to be processed by router: %s", n.options.Id)
continue continue
} }
// create an advert and process it // create an advert and process it

View File

@ -363,7 +363,7 @@ func (t *tun) process() {
// send the message // send the message
for _, link := range sendTo { for _, link := range sendTo {
// send the message via the current link // send the message via the current link
log.Debugf("Sending %+v to %s", newMsg.Header, link.Remote()) log.Tracef("Sending %+v to %s", newMsg.Header, link.Remote())
if errr := link.Send(newMsg); errr != nil { if errr := link.Send(newMsg); errr != nil {
log.Debugf("Tunnel error sending %+v to %s: %v", newMsg.Header, link.Remote(), errr) log.Debugf("Tunnel error sending %+v to %s: %v", newMsg.Header, link.Remote(), errr)
@ -548,7 +548,7 @@ func (t *tun) listen(link *link) {
// a continued session // a continued session
case "session": case "session":
// process message // process message
log.Debugf("Received %+v from %s", msg.Header, link.Remote()) log.Tracef("Received %+v from %s", msg.Header, link.Remote())
// an announcement of a channel listener // an announcement of a channel listener
case "announce": case "announce":
// process the announcement // process the announcement

View File

@ -321,7 +321,7 @@ func (s *session) Send(m *transport.Message) error {
msg.link = "" msg.link = ""
} }
log.Debugf("Appending %+v to send backlog", msg) log.Tracef("Appending %+v to send backlog", msg)
// send the actual message // send the actual message
s.send <- msg s.send <- msg
@ -352,7 +352,7 @@ func (s *session) Recv(m *transport.Message) error {
default: default:
} }
log.Debugf("Received %+v from recv backlog", msg) log.Tracef("Received %+v from recv backlog", msg)
// set message // set message
*m = *msg.data *m = *msg.data
// return nil // return nil