From 7c5b9c0e62fc1ec113f12b81e70735e4fb84dc1e Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Tue, 14 Feb 2023 14:21:33 -0600 Subject: [PATCH] only log expiry if applicable --- server/server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/server.go b/server/server.go index 16771332..8a4655be 100644 --- a/server/server.go +++ b/server/server.go @@ -1420,8 +1420,12 @@ func (s *Server) execManager() { defer s.mu.Unlock() for _, t := range s.topics { subs := t.SubscribersCount() - expiryTime := time.Until(t.lastVisitorExpires) - log.Tag(tagManager).Trace("- topic %s: %d subscribers, expires in %s", t.ID, subs, expiryTime) + expiryMessage := "" + if subs == 0 { + expiryTime := time.Until(t.lastVisitorExpires) + expiryMessage = ", expires in " + expiryTime.String() + } + log.Tag(tagManager).Trace("- topic %s: %d subscribers%s", t.ID, subs, expiryMessage) msgs, exists := messageCounts[t.ID] if t.Stale() && (!exists || msgs == 0) { log.Tag(tagManager).Trace("Deleting empty topic %s", t.ID)