From 53beccaed53ca0eaf08dfb08cb7196cd07fe846e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 24 Jun 2023 09:37:18 +0200 Subject: [PATCH] Harmonize capitalization of log messages --- agent.go | 10 +++++----- candidatepair.go | 2 +- selection.go | 14 +++++++------- tcp_mux.go | 2 +- tcp_packet_conn.go | 4 ++-- udp_mux.go | 12 ++++++------ 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/agent.go b/agent.go index c69ffad2..91eb784b 100644 --- a/agent.go +++ b/agent.go @@ -535,7 +535,7 @@ func (a *Agent) setSelectedPair(p *CandidatePair) { } func (a *Agent) pingAllCandidates() { - a.log.Trace("pinging all candidates") + a.log.Trace("Pinging all candidates") if len(a.checklist) == 0 { a.log.Warn("Failed to ping without candidate pairs. Connection is not possible yet.") @@ -549,7 +549,7 @@ func (a *Agent) pingAllCandidates() { } if p.bindingRequestCount > a.maxBindingRequests { - a.log.Tracef("max requests reached for pair %s, marking it as failed", p) + a.log.Tracef("Maximum requests reached for pair %s, marking it as failed", p) p.state = CandidatePairStateFailed } else { a.selector.PingCandidate(p.Local, p.Remote) @@ -959,7 +959,7 @@ func (a *Agent) findRemoteCandidate(networkType NetworkType, addr net.Addr) Cand } func (a *Agent) sendBindingRequest(m *stun.Message, local, remote Candidate) { - a.log.Tracef("ping STUN from %s to %s", local.String(), remote.String()) + a.log.Tracef("Ping STUN from %s to %s", local.String(), remote.String()) a.invalidatePendingBindingRequests(time.Now()) a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{ @@ -1041,7 +1041,7 @@ func (a *Agent) handleInbound(m *stun.Message, local Candidate, remote net.Addr) !(m.Type.Class == stun.ClassSuccessResponse || m.Type.Class == stun.ClassRequest || m.Type.Class == stun.ClassIndication) { - a.log.Tracef("unhandled STUN from %s to %s class(%s) method(%s)", remote, local, m.Type.Class, m.Type.Method) + a.log.Tracef("Unhandled STUN from %s to %s class(%s) method(%s)", remote, local, m.Type.Class, m.Type.Method) return } @@ -1109,7 +1109,7 @@ func (a *Agent) handleInbound(m *stun.Message, local Candidate, remote net.Addr) a.addRemoteCandidate(remoteCandidate) } - a.log.Tracef("inbound STUN (Request) from %s to %s", remote.String(), local.String()) + a.log.Tracef("Inbound STUN (Request) from %s to %s", remote.String(), local.String()) a.selector.HandleBindingRequest(m, local, remoteCandidate) } diff --git a/candidatepair.go b/candidatepair.go index f33be539..bd7fa427 100644 --- a/candidatepair.go +++ b/candidatepair.go @@ -97,6 +97,6 @@ func (p *CandidatePair) Write(b []byte) (int, error) { func (a *Agent) sendSTUN(msg *stun.Message, local, remote Candidate) { _, err := local.writeTo(msg.Raw, remote) if err != nil { - a.log.Tracef("failed to send STUN message: %s", err) + a.log.Tracef("Failed to send STUN message: %s", err) } } diff --git a/selection.go b/selection.go index 9f312637..f854581f 100644 --- a/selection.go +++ b/selection.go @@ -51,7 +51,7 @@ func (s *controllingSelector) ContactCandidates() { switch { case s.agent.getSelectedPair() != nil: if s.agent.validateSelectedPair() { - s.log.Trace("checking keepalive") + s.log.Trace("Checking keepalive") s.agent.checkKeepalive() } case s.nominatedPair != nil: @@ -87,7 +87,7 @@ func (s *controllingSelector) nominatePair(pair *CandidatePair) { return } - s.log.Tracef("ping STUN (nominate candidate pair) from %s to %s", pair.Local.String(), pair.Remote.String()) + s.log.Tracef("Ping STUN (nominate candidate pair) from %s to %s", pair.Local.String(), pair.Remote.String()) s.agent.sendBindingRequest(msg, pair.Local, pair.Remote) } @@ -130,7 +130,7 @@ func (s *controllingSelector) HandleSuccessResponse(m *stun.Message, local, remo return } - s.log.Tracef("inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String()) + s.log.Tracef("Inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String()) p := s.agent.findPair(local, remote) if p == nil { @@ -173,7 +173,7 @@ func (s *controlledSelector) Start() { func (s *controlledSelector) ContactCandidates() { if s.agent.getSelectedPair() != nil { if s.agent.validateSelectedPair() { - s.log.Trace("checking keepalive") + s.log.Trace("Checking keepalive") s.agent.checkKeepalive() } } else { @@ -221,7 +221,7 @@ func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remot return } - s.log.Tracef("inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String()) + s.log.Tracef("Inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String()) p := s.agent.findPair(local, remote) if p == nil { @@ -237,7 +237,7 @@ func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remot (selectedPair != p && selectedPair.priority() <= p.priority()) { s.agent.setSelectedPair(p) } else if selectedPair != p { - s.log.Tracef("ignore nominate new pair %s, already nominated pair %s", p, selectedPair) + s.log.Tracef("Ignore nominate new pair %s, already nominated pair %s", p, selectedPair) } } } @@ -262,7 +262,7 @@ func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote (selectedPair != p && selectedPair.priority() <= p.priority()) { s.agent.setSelectedPair(p) } else if selectedPair != p { - s.log.Tracef("ignore nominate new pair %s, already nominated pair %s", p, selectedPair) + s.log.Tracef("Ignore nominate new pair %s, already nominated pair %s", p, selectedPair) } } else { // If the received Binding request triggered a new check to be diff --git a/tcp_mux.go b/tcp_mux.go index fb4e5243..df169be2 100644 --- a/tcp_mux.go +++ b/tcp_mux.go @@ -191,7 +191,7 @@ func (m *TCPMuxDefault) handleConn(conn net.Conn) { } for _, attr := range msg.Attributes { - m.params.Logger.Debugf("msg attr: %s", attr.String()) + m.params.Logger.Debugf("Message attribute: %s", attr.String()) } attr, err := msg.Get(stun.AttrUsername) diff --git a/tcp_packet_conn.go b/tcp_packet_conn.go index 8c51fd1c..3f2a6b2c 100644 --- a/tcp_packet_conn.go +++ b/tcp_packet_conn.go @@ -56,12 +56,12 @@ func (bc *bufferedConn) writeProcess() { } if err != nil { - bc.logger.Warnf("read buffer error: %s", err) + bc.logger.Warnf("Failed to read from buffer: %s", err) continue } if _, err := bc.Conn.Write(pktBuf[:n]); err != nil { - bc.logger.Warnf("write error: %s", err) + bc.logger.Warnf("Failed to write: %s", err) continue } } diff --git a/udp_mux.go b/udp_mux.go index 405bb7b1..47084f83 100644 --- a/udp_mux.go +++ b/udp_mux.go @@ -89,7 +89,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault { if params.Net == nil { var err error if params.Net, err = stdnet.NewNet(); err != nil { - params.Logger.Errorf("failed to get create network: %v", err) + params.Logger.Errorf("Failed to get create network: %v", err) } } @@ -99,7 +99,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault { localAddrsForUnspecified = append(localAddrsForUnspecified, &net.UDPAddr{IP: ip, Port: addr.Port}) } } else { - params.Logger.Errorf("failed to get local interfaces for unspecified addr: %v", err) + params.Logger.Errorf("Failed to get local interfaces for unspecified addr: %v", err) } } } @@ -290,7 +290,7 @@ func (m *UDPMuxDefault) connWorker() { if os.IsTimeout(err) { continue } else if !errors.Is(err, io.EOF) { - logger.Errorf("could not read udp packet: %v", err) + logger.Errorf("Failed to read UDP packet: %v", err) } return @@ -298,7 +298,7 @@ func (m *UDPMuxDefault) connWorker() { udpAddr, ok := addr.(*net.UDPAddr) if !ok { - logger.Errorf("underlying PacketConn did not return a UDPAddr") + logger.Errorf("Underlying PacketConn did not return a UDPAddr") return } @@ -333,12 +333,12 @@ func (m *UDPMuxDefault) connWorker() { } if destinationConn == nil { - m.params.Logger.Tracef("dropping packet from %s, addr: %s", udpAddr.String(), addr.String()) + m.params.Logger.Tracef("Dropping packet from %s, addr: %s", udpAddr.String(), addr.String()) continue } if err = destinationConn.writePacket(buf[:n], udpAddr); err != nil { - m.params.Logger.Errorf("could not write packet: %v", err) + m.params.Logger.Errorf("Failed to write packet: %v", err) } } }