From 8e570571adbe57efb476205cd4695f3b32c3c54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=91=E5=99=A8=E8=BF=91?= Date: Wed, 16 Jun 2021 15:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/github/yezhihao/netmc/TCPServerHandler.java | 8 ++++---- .../yezhihao/netmc/codec/MessageDecoderWrapper.java | 2 +- .../yezhihao/netmc/codec/MessageEncoderWrapper.java | 2 +- .../java/io/github/yezhihao/netmc/session/Session.java | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/yezhihao/netmc/TCPServerHandler.java b/src/main/java/io/github/yezhihao/netmc/TCPServerHandler.java index b22deef..d8e8bb1 100644 --- a/src/main/java/io/github/yezhihao/netmc/TCPServerHandler.java +++ b/src/main/java/io/github/yezhihao/netmc/TCPServerHandler.java @@ -67,7 +67,7 @@ public class TCPServerHandler extends ChannelInboundHandlerAdapter { } time = System.currentTimeMillis() - time; if (time > 200) - log.info("========={},处理耗时{}ms,", request.getMessageName(), time); + log.info("====={},处理耗时{}ms,", request.getMessageName(), time); if (response != null) ctx.writeAndFlush(response); } @@ -77,20 +77,20 @@ public class TCPServerHandler extends ChannelInboundHandlerAdapter { Channel channel = ctx.channel(); Session session = sessionManager.newSession(channel); channel.attr(Session.KEY).set(session); - log.info(">>>>>终端连接{}", session); + log.info("<<<<<终端连接{}", session); } @Override public void channelInactive(ChannelHandlerContext ctx) { Session session = ctx.channel().attr(Session.KEY).get(); session.invalidate(); - log.info("<<<<<断开连接{}", session); + log.info(">>>>>断开连接{}", session); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { Session session = ctx.channel().attr(Session.KEY).get(); - log.warn("<<<<<消息处理异常" + session, e); + log.warn(">>>>>消息处理异常" + session, e); } @Override diff --git a/src/main/java/io/github/yezhihao/netmc/codec/MessageDecoderWrapper.java b/src/main/java/io/github/yezhihao/netmc/codec/MessageDecoderWrapper.java index c7a7fee..c41915c 100644 --- a/src/main/java/io/github/yezhihao/netmc/codec/MessageDecoderWrapper.java +++ b/src/main/java/io/github/yezhihao/netmc/codec/MessageDecoderWrapper.java @@ -37,7 +37,7 @@ public class MessageDecoderWrapper extends ChannelInboundHandlerAdapter { hex = ByteBufUtil.hexDump(buf); else hex = ByteBufUtil.hexDump(buf.slice(0, 32)) + "..." + ByteBufUtil.hexDump(buf.slice(buf.readableBytes() - 32, 32)); - log.info(">>>>>原始报文[ip={}],hex={}", ctx.channel().remoteAddress(), hex); + log.info("<<<<<[ip={}],payload={}", ctx.channel().remoteAddress(), hex); } Object message = decoder.decode(buf, ctx.channel().attr(Session.KEY).get()); if (message != null) diff --git a/src/main/java/io/github/yezhihao/netmc/codec/MessageEncoderWrapper.java b/src/main/java/io/github/yezhihao/netmc/codec/MessageEncoderWrapper.java index 38c133b..e549817 100644 --- a/src/main/java/io/github/yezhihao/netmc/codec/MessageEncoderWrapper.java +++ b/src/main/java/io/github/yezhihao/netmc/codec/MessageEncoderWrapper.java @@ -36,7 +36,7 @@ public class MessageEncoderWrapper extends ChannelOutboundHandlerAdapter { else buf = encoder.encode(msg); if (log.isInfoEnabled()) - log.info("<<<<<原始报文[ip={}],hex={}", ctx.channel().remoteAddress(), ByteBufUtil.hexDump(buf)); + log.info(">>>>>[ip={}],payload={}", ctx.channel().remoteAddress(), ByteBufUtil.hexDump(buf)); if (buf.isReadable()) { ctx.write(buf, promise); diff --git a/src/main/java/io/github/yezhihao/netmc/session/Session.java b/src/main/java/io/github/yezhihao/netmc/session/Session.java index d4d0d72..6ccae2a 100644 --- a/src/main/java/io/github/yezhihao/netmc/session/Session.java +++ b/src/main/java/io/github/yezhihao/netmc/session/Session.java @@ -168,14 +168,14 @@ public class Session { private static final ChannelFutureListener ERROR_LOG_LISTENER = future -> { Throwable t = future.cause(); if (t != null) - log.error("<<<<<<<<<<消息下发失败", t); + log.error(">>>>>>>>>>消息下发失败", t); }; /** * 发送通知类消息,不接收响应 */ public void notify(Object message) { - log.info("<<<<<<<<<<消息通知{},{}", this, message); + log.info(">>>>>>>>>>消息通知{},{}", this, message); channel.writeAndFlush(message).addListener(ERROR_LOG_LISTENER); } @@ -191,17 +191,17 @@ public class Session { String key = requestKey(request, responseClass); SynchronousQueue syncQueue = this.subscribe(key); if (syncQueue == null) { - log.info("<<<<<<<<<<请勿重复发送,{}", request); + log.info("==========请勿重复发送,{}", request); } T result = null; try { - log.info("<<<<<<<<<<消息请求{},{}", this, request); + log.info(">>>>>>>>>>消息请求{},{}", this, request); ChannelFuture channelFuture = channel.writeAndFlush(request).addListener(ERROR_LOG_LISTENER); if (channelFuture.awaitUninterruptibly().isSuccess()) result = (T) syncQueue.poll(timeout, TimeUnit.MILLISECONDS); } catch (Throwable e) { - log.warn("<<<<<<<<<<等待响应超时" + this, e); + log.warn(">>>>>>>>>>等待响应超时" + this, e); } finally { this.unsubscribe(key); }