chore(gb32960): demote high-frequency report/heartbeat ack logs to DEBUG

Every 0x02/0x03/0x07 ack produced an INFO line that, at one report per
vehicle every few seconds across many vehicles, drowns out meaningful
events in the log stream.

writeAck now checks the tag string: tags starting with "report-ack-" or
"heartbeat-ack" log their success at DEBUG (guarded by isDebugEnabled to
avoid building the hex dump string when DEBUG is off). Sparse ack tags
-- vehicle-login-ack / vehicle-logout-ack / platform-login-ack /
platform-logout-ack / time-calibration-ack -- keep INFO for audit.
Flush *failure* is still WARN for every tag so problems are never
silenced.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lingniu-dev
2026-04-15 17:43:52 +08:00
parent e8150114df
commit d8279ac3b7

View File

@@ -240,14 +240,30 @@ public class Gb32960ChannelHandler extends SimpleChannelInboundHandler<byte[]> {
dispatcher.dispatch(rf);
}
/** 统一的 ack 写出 + 日志确认(含完整 hex dump 便于排查对端行为)。 */
/**
* 统一的 ack 写出 + 日志确认。
*
* <p>高频 ack实时/补发上报 0x02/0x03、心跳 0x07的成功事件降级为 DEBUG避免每帧
* 一条 INFO 淹没日志;稀疏的登入/登出/校时 ack 仍保留 INFO 以便审计。写入失败无论
* 哪个标签都走 WARN不会被抑制。
*/
private static void writeAck(ChannelHandlerContext ctx, byte[] ack, String tag) {
String hex = hex(ack);
boolean highFrequency = tag.startsWith("report-ack-") || tag.startsWith("heartbeat-ack");
ctx.writeAndFlush(Unpooled.wrappedBuffer(ack)).addListener(f -> {
if (f.isSuccess()) {
log.info("[gb32960] {} flushed peer={} len={} hex={}", tag, addr(ctx), ack.length, hex);
if (highFrequency) {
if (log.isDebugEnabled()) {
log.debug("[gb32960] {} flushed peer={} len={} hex={}",
tag, addr(ctx), ack.length, hex);
}
} else {
log.info("[gb32960] {} flushed peer={} len={} hex={}",
tag, addr(ctx), ack.length, hex);
}
} else {
log.warn("[gb32960] {} flush FAILED peer={} len={} hex={}", tag, addr(ctx), ack.length, hex, f.cause());
log.warn("[gb32960] {} flush FAILED peer={} len={} hex={}",
tag, addr(ctx), ack.length, hex, f.cause());
}
});
}