From f2f5609c6ee344374ec2897a95654a88edeeefde Mon Sep 17 00:00:00 2001 From: bcmmbaga Date: Fri, 26 Jul 2024 11:51:41 +0300 Subject: [PATCH] Refactor log statement for peer status trace Move the peer status trace log inside a conditional block to ensure it only logs when the peer status is not connected. This refactor prevents unnecessary logging and streamlines the execution trace. --- management/server/sql_store.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/management/server/sql_store.go b/management/server/sql_store.go index 0d86564fc..92471472f 100644 --- a/management/server/sql_store.go +++ b/management/server/sql_store.go @@ -309,9 +309,11 @@ func (s *SqlStore) SavePeerStatus(accountID, peerID string, peerStatus nbpeer.Pe var peerCopy nbpeer.Peer peerCopy.Status = &peerStatus - log.WithContext(context.Background()).Tracef("saving peer: %s with false status. PeerCopy %v, Arg: %v, Trace: %s", - peerID, peerCopy.Status.Connected, peerStatus.Connected, - debug.Stack()) + if !peerStatus.Connected { + log.WithContext(context.Background()).Tracef("saving peer: %s with false status. PeerCopy %v, Arg: %v, Trace: %s", + peerID, peerCopy.Status.Connected, peerStatus.Connected, + debug.Stack()) + } fieldsToUpdate := []string{ "peer_status_last_seen", "peer_status_connected",