From 919741838db3c6eb80f324934562eda67c4519eb Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Wed, 12 Feb 2020 09:37:16 -0600 Subject: [PATCH] fix use of hclog logger (#7264) --- agent/consul/rpc.go | 7 +++---- connect/service.go | 2 +- snapshot/snapshot.go | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/agent/consul/rpc.go b/agent/consul/rpc.go index 248c0c82c..2391a847c 100644 --- a/agent/consul/rpc.go +++ b/agent/consul/rpc.go @@ -68,8 +68,7 @@ func (s *Server) listen(listener net.Listener) { free, err := s.rpcConnLimiter.Accept(conn) if err != nil { - s.rpcLogger().Error("rejecting RPC conn from %s"+ - " rpc_max_conns_per_client exceeded", conn.RemoteAddr().String()) + s.rpcLogger().Error("rejecting RPC conn from because rpc_max_conns_per_client exceeded", "conn", logConn(conn)) conn.Close() continue } @@ -138,7 +137,7 @@ func (s *Server) handleConn(conn net.Conn, isTLS bool) { case pool.RPCTLS: // Don't allow malicious client to create TLS-in-TLS for ever. if isTLS { - s.rpcLogger().Error("TLS connection attempting to establish inner TLS connection %s", logConn(conn)) + s.rpcLogger().Error("TLS connection attempting to establish inner TLS connection", "conn", logConn(conn)) conn.Close() return } @@ -154,7 +153,7 @@ func (s *Server) handleConn(conn net.Conn, isTLS bool) { case pool.RPCTLSInsecure: // Don't allow malicious client to create TLS-in-TLS for ever. if isTLS { - s.rpcLogger().Error("TLS connection attempting to establish inner TLS connection %s", logConn(conn)) + s.rpcLogger().Error("TLS connection attempting to establish inner TLS connection", "conn", logConn(conn)) conn.Close() return } diff --git a/connect/service.go b/connect/service.go index 2452b3e67..cf8531949 100644 --- a/connect/service.go +++ b/connect/service.go @@ -205,7 +205,7 @@ func (s *Service) Dial(ctx context.Context, resolver Resolver) (net.Conn, error) tlsConn.Close() return nil, err } - s.logger.Debug("successfully connected to service instance", addr, + s.logger.Debug("successfully connected to service instance", "address", addr, "identity", certURI.URI(), ) diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index 0421450b8..f2dc520b0 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -40,7 +40,7 @@ func New(logger hclog.Logger, r *raft.Raft) (*Snapshot, error) { } defer func() { if err := snap.Close(); err != nil { - logger.Error("Failed to close Raft snapshot: %v", err) + logger.Error("Failed to close Raft snapshot", "error", err) } }()