From 0210b70bda957579a9b262972dfffbc2ff611908 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 15 Aug 2026 18:19:41 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E6=97=A5=E5=BF=97):=20=E7=A9=BA=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=E4=B8=8D=E8=BE=93=E5=87=BA=20Info=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BB=A5=E5=87=8F=E5=B0=91=E5=99=AA=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Motivation: 轮询安全网关更新时,绝大多数周期没有新消息,持续输出 Info 日志会产生大量噪音并带来不必要的开销。仅在确有更新时才记录日志,便于聚焦真实事件。 Changes: * 仅在存在更新时输出 getUpdates 日志 * 仅在拉取到群聊数据时输出 poll 日志 --- internal/adapter/safew.go | 4 +++- internal/safew/watcher.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/adapter/safew.go b/internal/adapter/safew.go index f5c41a8..0660f6d 100644 --- a/internal/adapter/safew.go +++ b/internal/adapter/safew.go @@ -178,7 +178,9 @@ func (s *SafeWSender) PollGroupChats(token string, offset int64, timeout int) ([ if maxID > 0 { next = maxID + 1 } - slog.Info("safew getUpdates", "timeout", timeout, "updates", n, "groups", len(chats), "offset", next) + if n > 0 { + slog.Info("safew getUpdates", "timeout", timeout, "updates", n, "groups", len(chats), "offset", next) + } return chats, next, nil } diff --git a/internal/safew/watcher.go b/internal/safew/watcher.go index 6672c07..075230a 100644 --- a/internal/safew/watcher.go +++ b/internal/safew/watcher.go @@ -196,7 +196,9 @@ func (w *Watcher) pollOnce(ctx context.Context, token string, timeout int) error if err != nil { return err } - slog.Info("safew poll", "timeout", timeout, "groups", len(chats), "offset", next) + if len(chats) > 0 { + slog.Info("safew poll", "timeout", timeout, "groups", len(chats), "offset", next) + } if err := w.mergeAndLog(ctx, token, chats); err != nil { return err }