From ce9a0b7edfc513a9560bf189db60295db71cc254 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 5 May 2020 20:38:53 +0300 Subject: [PATCH] use log.Warn instead of Warning --- comm.go | 4 ++-- discovery.go | 4 ++-- gossipsub.go | 10 +++++----- pubsub.go | 18 +++++++++--------- score.go | 4 ++-- tracer.go | 2 +- validation.go | 12 ++++++------ 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/comm.go b/comm.go index 24ad6f9..c593e23 100644 --- a/comm.go +++ b/comm.go @@ -71,7 +71,7 @@ func (p *PubSub) handleNewStream(s network.Stream) { func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan *RPC) { s, err := p.host.NewStream(p.ctx, pid, p.rt.Protocols()...) if err != nil { - log.Warning("opening new stream to peer: ", err, pid) + log.Warn("opening new stream to peer: ", err, pid) var ch chan peer.ID if err == ms.ErrNotSupported { @@ -107,7 +107,7 @@ func (p *PubSub) handlePeerEOF(ctx context.Context, s network.Stream) { } return } - log.Warning("unexpected message from ", s.Conn().RemotePeer()) + log.Warn("unexpected message from ", s.Conn().RemotePeer()) } } diff --git a/discovery.go b/discovery.go index a4e20f3..4a468a0 100644 --- a/discovery.go +++ b/discovery.go @@ -189,7 +189,7 @@ func (d *discover) Advertise(topic string) { go func() { next, err := d.discovery.Advertise(advertisingCtx, topic) if err != nil { - log.Warningf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) + log.Warnf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) if next == 0 { next = discoveryAdvertiseRetryInterval } @@ -203,7 +203,7 @@ func (d *discover) Advertise(topic string) { case <-t.C: next, err = d.discovery.Advertise(advertisingCtx, topic) if err != nil { - log.Warningf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) + log.Warnf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) if next == 0 { next = discoveryAdvertiseRetryInterval } diff --git a/gossipsub.go b/gossipsub.go index da3bf8e..aa499d9 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -526,7 +526,7 @@ func (gs *GossipSubRouter) handleGraft(p peer.ID, ctl *pb.ControlMessage) []*pb. // we don't GRAFT to/from direct peers; complain loudly if this happens _, direct := gs.direct[p] if direct { - log.Warningf("GRAFT: ignoring request from direct peer %s", p) + log.Warnf("GRAFT: ignoring request from direct peer %s", p) // this is possibly a bug from non-reciprocal configuration; send a PRUNE prune = append(prune, topic) // but don't PX @@ -654,16 +654,16 @@ func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) { // the peer sent us a signed record; ensure that it is valid envelope, r, err := record.ConsumeEnvelope(pi.SignedPeerRecord, peer.PeerRecordEnvelopeDomain) if err != nil { - log.Warningf("error unmarshalling peer record obtained through px: %s", err) + log.Warnf("error unmarshalling peer record obtained through px: %s", err) continue } rec, ok := r.(*peer.PeerRecord) if !ok { - log.Warningf("bogus peer record obtained through px: envelope payload is not PeerRecord") + log.Warnf("bogus peer record obtained through px: envelope payload is not PeerRecord") continue } if rec.PeerID != p { - log.Warningf("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s", rec.PeerID, p) + log.Warnf("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s", rec.PeerID, p) continue } spr = envelope @@ -1384,7 +1384,7 @@ func (gs *GossipSubRouter) makePrune(p peer.ID, topic string, doPX bool) *pb.Con if spr != nil { recordBytes, err = spr.Marshal() if err != nil { - log.Warningf("error marshaling signed peer record for %s: %s", p, err) + log.Warnf("error marshaling signed peer record for %s: %s", p, err) } } } diff --git a/pubsub.go b/pubsub.go index a3f5078..9e30a76 100644 --- a/pubsub.go +++ b/pubsub.go @@ -426,12 +426,12 @@ func (p *PubSub) processLoop(ctx context.Context) { select { case pid := <-p.newPeers: if _, ok := p.peers[pid]; ok { - log.Warning("already have connection to peer: ", pid) + log.Warn("already have connection to peer: ", pid) continue } if p.blacklist.Contains(pid) { - log.Warning("ignoring connection from blacklisted peer: ", pid) + log.Warn("ignoring connection from blacklisted peer: ", pid) continue } @@ -445,13 +445,13 @@ func (p *PubSub) processLoop(ctx context.Context) { ch, ok := p.peers[pid] if !ok { - log.Warning("new stream for unknown peer: ", pid) + log.Warn("new stream for unknown peer: ", pid) s.Reset() continue } if p.blacklist.Contains(pid) { - log.Warning("closing stream for blacklisted peer: ", pid) + log.Warn("closing stream for blacklisted peer: ", pid) close(ch) s.Reset() continue @@ -473,7 +473,7 @@ func (p *PubSub) processLoop(ctx context.Context) { if p.host.Network().Connectedness(pid) == network.Connected { // still connected, must be a duplicate connection being closed. // we respawn the writer as we need to ensure there is a stream active - log.Warning("peer declared dead but still connected; respawning writer: ", pid) + log.Warn("peer declared dead but still connected; respawning writer: ", pid) messages := make(chan *RPC, p.peerOutboundQueueSize) messages <- p.getHelloPacket() go p.handleNewPeer(ctx, pid, messages) @@ -886,13 +886,13 @@ func (p *PubSub) handleIncomingRPC(rpc *RPC) { // ask the router to vet the peer before commiting any processing resources if !p.rt.AcceptFrom(rpc.from) { - log.Warningf("received message from router graylisted peer %s. Dropping RPC", rpc.from) + log.Warnf("received message from router graylisted peer %s. Dropping RPC", rpc.from) return } for _, pmsg := range rpc.GetPublish() { if !(p.subscribedToMsg(pmsg) || p.canRelayMsg(pmsg)) { - log.Warning("received message we didn't subscribe to. Dropping.") + log.Warn("received message we didn't subscribe to. Dropping.") continue } @@ -913,14 +913,14 @@ func (p *PubSub) pushMsg(msg *Message) { src := msg.ReceivedFrom // reject messages from blacklisted peers if p.blacklist.Contains(src) { - log.Warningf("dropping message from blacklisted peer %s", src) + log.Warnf("dropping message from blacklisted peer %s", src) p.tracer.RejectMessage(msg, rejectBlacklstedPeer) return } // even if they are forwarded by good peers if p.blacklist.Contains(msg.GetFrom()) { - log.Warningf("dropping message from blacklisted source %s", src) + log.Warnf("dropping message from blacklisted source %s", src) p.tracer.RejectMessage(msg, rejectBlacklistedSource) return } diff --git a/score.go b/score.go index 735b291..2535de4 100644 --- a/score.go +++ b/score.go @@ -514,7 +514,7 @@ func (ps *peerScore) DeliverMessage(msg *Message) { // defensive check that this is the first delivery trace -- delivery status should be unknown if drec.status != deliveryUnknown { - log.Warningf("unexpected delivery trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) + log.Warnf("unexpected delivery trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) return } @@ -561,7 +561,7 @@ func (ps *peerScore) RejectMessage(msg *Message, reason string) { // defensive check that this is the first rejection trace -- delivery status should be unknown if drec.status != deliveryUnknown { - log.Warningf("unexpected rejection trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) + log.Warnf("unexpected rejection trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) return } diff --git a/tracer.go b/tracer.go index 832f35f..ad386fa 100644 --- a/tracer.go +++ b/tracer.go @@ -54,7 +54,7 @@ func (t *basicTracer) Trace(evt *pb.TraceEvent) { } if t.lossy && len(t.buf) > TraceBufferSize { - log.Warningf("trace buffer overflow; dropping trace event") + log.Warnf("trace buffer overflow; dropping trace event") } else { t.buf = append(t.buf, evt) } diff --git a/validation.go b/validation.go index 480b83d..9fe9331 100644 --- a/validation.go +++ b/validation.go @@ -200,7 +200,7 @@ func (v *validation) Push(src peer.ID, msg *Message) bool { select { case v.validateQ <- &validateReq{vals, src, msg}: default: - log.Warningf("message validation throttled: queue full; dropping message from %s", src) + log.Warnf("message validation throttled: queue full; dropping message from %s", src) v.tracer.RejectMessage(msg, rejectValidationQueueFull) } return false @@ -243,7 +243,7 @@ func (v *validation) validateWorker() { func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) { if msg.Signature != nil { if !v.validateSignature(msg) { - log.Warningf("message signature validation failed; dropping message from %s", src) + log.Warnf("message signature validation failed; dropping message from %s", src) v.tracer.RejectMessage(msg, rejectInvalidSignature) return } @@ -282,7 +282,7 @@ func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) { } if result == ValidationReject { - log.Warningf("message validation failed; dropping message from %s", src) + log.Warnf("message validation failed; dropping message from %s", src) v.tracer.RejectMessage(msg, rejectValidationFailed) return } @@ -296,7 +296,7 @@ func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) { <-v.validateThrottle }() default: - log.Warningf("message validation throttled; dropping message from %s", src) + log.Warnf("message validation throttled; dropping message from %s", src) v.tracer.RejectMessage(msg, rejectValidationThrottled) } return @@ -340,7 +340,7 @@ func (v *validation) doValidateTopic(vals []*topicVal, src peer.ID, msg *Message v.tracer.RejectMessage(msg, rejectValidationIgnored) return case validationThrottled: - log.Warningf("message validation throttled; ignoring message from %s", src) + log.Warnf("message validation throttled; ignoring message from %s", src) v.tracer.RejectMessage(msg, rejectValidationThrottled) default: @@ -428,7 +428,7 @@ func (val *topicVal) validateMsg(ctx context.Context, src peer.ID, msg *Message) return r default: - log.Warningf("Unexpected result from validator: %d; ignoring message", r) + log.Warnf("Unexpected result from validator: %d; ignoring message", r) return ValidationIgnore } }