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:
@@ -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.warn("[gb32960] {} flush FAILED peer={} len={} hex={}", tag, addr(ctx), ack.length, hex, f.cause());
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user