From 1690e9d30de3b59c9f78b65839a24c0dc4cca9a9 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 26 Aug 2020 06:56:17 -0500 Subject: [PATCH 1/2] Issue #5193 - Adding more EventDriver logging Signed-off-by: Joakim Erdfelt --- .../common/events/AbstractEventDriver.java | 27 ++++--- .../events/JettyAnnotatedEventDriver.java | 68 +++++++++++++++- .../common/events/JettyAnnotatedMetadata.java | 15 ++-- .../events/JettyListenerEventDriver.java | 79 ++++++++++++++++++- .../events/annotated/CallableMethod.java | 5 +- .../OptionalSessionCallableMethod.java | 7 +- 6 files changed, 176 insertions(+), 25 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java index 2c54ace5c183..d69fe68044fc 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.util.Objects; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Utf8Appendable.NotUtf8Exception; @@ -42,7 +43,7 @@ */ public abstract class AbstractEventDriver extends AbstractLifeCycle implements IncomingFrames, EventDriver { - private static final Logger LOG = Log.getLogger(AbstractEventDriver.class); + private final Logger logger; protected final Logger targetLog; protected WebSocketPolicy policy; protected final Object websocket; @@ -51,8 +52,9 @@ public abstract class AbstractEventDriver extends AbstractLifeCycle implements I public AbstractEventDriver(WebSocketPolicy policy, Object websocket) { + this.logger = Log.getLogger(this.getClass()); this.policy = policy; - this.websocket = websocket; + this.websocket = Objects.requireNonNull(websocket, "WebSocket endpoint may not be null"); this.targetLog = Log.getLogger(websocket.getClass()); } @@ -87,9 +89,9 @@ public WebSocketSession getSession() @Override public void incomingFrame(Frame frame) { - if (LOG.isDebugEnabled()) + if (logger.isDebugEnabled()) { - LOG.debug("incomingFrame({})", frame); + logger.debug("incomingFrame({})", frame); } try @@ -112,9 +114,9 @@ public void incomingFrame(Frame frame) } case OpCode.PING: { - if (LOG.isDebugEnabled()) + if (logger.isDebugEnabled()) { - LOG.debug("PING: {}", BufferUtil.toDetailString(frame.getPayload())); + logger.debug("PING: {}", BufferUtil.toDetailString(frame.getPayload())); } ByteBuffer pongBuf; if (frame.hasPayload()) @@ -133,9 +135,9 @@ public void incomingFrame(Frame frame) } case OpCode.PONG: { - if (LOG.isDebugEnabled()) + if (logger.isDebugEnabled()) { - LOG.debug("PONG: {}", BufferUtil.toDetailString(frame.getPayload())); + logger.debug("PONG: {}", BufferUtil.toDetailString(frame.getPayload())); } onPong(frame.getPayload()); break; @@ -157,8 +159,8 @@ public void incomingFrame(Frame frame) } default: { - if (LOG.isDebugEnabled()) - LOG.debug("Unhandled OpCode: {}", opcode); + if (logger.isDebugEnabled()) + logger.debug("Unhandled OpCode: {}", opcode); } } } @@ -202,10 +204,9 @@ public BatchMode getBatchMode() @Override public void openSession(WebSocketSession session) { - if (LOG.isDebugEnabled()) + if (logger.isDebugEnabled()) { - LOG.debug("openSession({})", session); - LOG.debug("objectFactory={}", session.getContainerScope().getObjectFactory()); + logger.debug("openSession({}) objectFactory={}", session, session.getContainerScope().getObjectFactory()); } this.session = session; this.session.getContainerScope().getObjectFactory().decorate(this.websocket); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java index cb993d213d0b..5bec0316252f 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java @@ -22,7 +22,9 @@ import java.io.InputStream; import java.io.Reader; import java.nio.ByteBuffer; +import java.util.Objects; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.BatchMode; @@ -36,6 +38,7 @@ import org.eclipse.jetty.websocket.common.message.NullMessage; import org.eclipse.jetty.websocket.common.message.SimpleBinaryMessage; import org.eclipse.jetty.websocket.common.message.SimpleTextMessage; +import org.eclipse.jetty.websocket.common.util.TextUtil; /** * Handler for Annotated User WebSocket objects. @@ -50,7 +53,7 @@ public class JettyAnnotatedEventDriver extends AbstractEventDriver public JettyAnnotatedEventDriver(WebSocketPolicy policy, Object websocket, JettyAnnotatedMetadata events) { super(policy, websocket); - this.events = events; + this.events = Objects.requireNonNull(events, "JettyAnnotatedMetadata may not be null"); WebSocket anno = websocket.getClass().getAnnotation(WebSocket.class); // Setup the policy @@ -71,6 +74,11 @@ public JettyAnnotatedEventDriver(WebSocketPolicy policy, Object websocket, Jetty this.policy.setIdleTimeout(anno.maxIdleTime()); } this.batchMode = anno.batchMode(); + + if (LOG.isDebugEnabled()) + { + LOG.debug("ctor / object={}, policy={}, batchMode={}, events={}", websocket, policy, batchMode, events); + } } @Override @@ -82,6 +90,11 @@ public BatchMode getBatchMode() @Override public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException { + if (LOG.isDebugEnabled()) + { + LOG.debug("onBinaryFrame({}, {}) - events.onBinary={}", BufferUtil.toDetailString(buffer), fin, events.onBinary); + } + if (events.onBinary == null) { // not interested in binary events @@ -126,6 +139,11 @@ public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException @Override public void onBinaryMessage(byte[] data) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onBinaryMessage([{}]) - events.onBinary={}", data.length, events.onBinary); + } + if (events.onBinary != null) { events.onBinary.call(websocket, session, data, 0, data.length); @@ -141,6 +159,12 @@ public void onClose(CloseInfo close) return; } hasCloseBeenCalled = true; + + if (LOG.isDebugEnabled()) + { + LOG.debug("onClose({}) - events.onClose={}", close, events.onClose); + } + if (events.onClose != null) { events.onClose.call(websocket, session, close.getStatusCode(), close.getReason()); @@ -150,6 +174,11 @@ public void onClose(CloseInfo close) @Override public void onConnect() { + if (LOG.isDebugEnabled()) + { + LOG.debug("onConnect() - events.onConnect={}", events.onConnect); + } + if (events.onConnect != null) { events.onConnect.call(websocket, session); @@ -159,6 +188,11 @@ public void onConnect() @Override public void onError(Throwable cause) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onError({}) - events.onError={}", cause.getClass().getName(), events.onError); + } + if (events.onError != null) { events.onError.call(websocket, session, cause); @@ -172,6 +206,11 @@ public void onError(Throwable cause) @Override public void onFrame(Frame frame) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onFrame({}) - events.onFrame={}", frame, events.onFrame); + } + if (events.onFrame != null) { events.onFrame.call(websocket, session, frame); @@ -181,6 +220,13 @@ public void onFrame(Frame frame) @Override public void onInputStream(InputStream stream) { + Objects.requireNonNull(stream, "InputStream may not be null"); + + if (LOG.isDebugEnabled()) + { + LOG.debug("onInputStream({}) - events.onBinary={}", stream.getClass().getName(), events.onBinary); + } + if (events.onBinary != null) { events.onBinary.call(websocket, session, stream); @@ -190,6 +236,13 @@ public void onInputStream(InputStream stream) @Override public void onReader(Reader reader) { + Objects.requireNonNull(reader, "Reader may not be null"); + + if (LOG.isDebugEnabled()) + { + LOG.debug("onReader({}) - events.onText={}", reader.getClass().getName(), events.onText); + } + if (events.onText != null) { events.onText.call(websocket, session, reader); @@ -199,6 +252,11 @@ public void onReader(Reader reader) @Override public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException { + if (LOG.isDebugEnabled()) + { + LOG.debug("onTextFrame({}, {}) - events.onText={}", BufferUtil.toDetailString(buffer), fin, events.onText); + } + if (events.onText == null) { // not interested in text events @@ -243,6 +301,14 @@ public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException @Override public void onTextMessage(String message) { + if (LOG.isDebugEnabled()) + { + if (message == null) + LOG.debug("onTextMessage() - events.onText={}", events.onText); + else + LOG.debug("onTextMessage([{}] \"{}\") - events.onText={}", message.length(), TextUtil.maxStringLength(60, message), events.onText); + } + if (events.onText != null) { events.onText.call(websocket, session, message); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedMetadata.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedMetadata.java index 536faeaaf2a5..c56f9efb89fb 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedMetadata.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedMetadata.java @@ -24,27 +24,27 @@ public class JettyAnnotatedMetadata { /** - * @OnWebSocketConnect () + * {@code @OnWebSocketConnect ()} */ public CallableMethod onConnect; /** - * @OnWebSocketMessage (byte[], or ByteBuffer, or InputStream) + * {@code @OnWebSocketMessage (byte[], or ByteBuffer, or InputStream)} */ public OptionalSessionCallableMethod onBinary; /** - * @OnWebSocketMessage (String, or Reader) + * {@code @OnWebSocketMessage (String, or Reader)} */ public OptionalSessionCallableMethod onText; /** - * @OnWebSocketFrame (Frame) + * {@code @OnWebSocketFrame (Frame)} */ public OptionalSessionCallableMethod onFrame; /** - * @OnWebSocketError (Throwable) + * {@code @OnWebSocketError (Throwable)} */ public OptionalSessionCallableMethod onError; /** - * @OnWebSocketClose (Frame) + * {@code @OnWebSocketClose (Frame)} */ public OptionalSessionCallableMethod onClose; @@ -52,7 +52,8 @@ public class JettyAnnotatedMetadata public String toString() { StringBuilder s = new StringBuilder(); - s.append("JettyPojoMetadata["); + s.append(this.getClass().getSimpleName()); + s.append("["); s.append("onConnect=").append(onConnect); s.append(",onBinary=").append(onBinary); s.append(",onText=").append(onText); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java index 9af52f99937a..fcf85a1a5941 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java @@ -22,7 +22,9 @@ import java.io.InputStream; import java.io.Reader; import java.nio.ByteBuffer; +import java.util.Objects; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -38,6 +40,7 @@ import org.eclipse.jetty.websocket.common.frames.ReadOnlyDelegatedFrame; import org.eclipse.jetty.websocket.common.message.SimpleBinaryMessage; import org.eclipse.jetty.websocket.common.message.SimpleTextMessage; +import org.eclipse.jetty.websocket.common.util.TextUtil; /** * Handler for {@link WebSocketListener} based User WebSocket implementations. @@ -58,12 +61,25 @@ private enum PartialMode public JettyListenerEventDriver(WebSocketPolicy policy, WebSocketConnectionListener listener) { super(policy, listener); - this.listener = listener; + this.listener = Objects.requireNonNull(listener, "Listener may not be null"); + if (LOG.isDebugEnabled()) + { + LOG.debug("ctor / listener={}, policy={}", listener.getClass().getName(), policy); + } } @Override public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException { + if (LOG.isDebugEnabled()) + { + LOG.debug("onBinaryFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + BufferUtil.toDetailString(buffer), fin, + (listener instanceof WebSocketListener), + (listener instanceof WebSocketPartialListener), + listener.getClass().getName()); + } + if (listener instanceof WebSocketListener) { if (activeMessage == null) @@ -98,6 +114,14 @@ public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException @Override public void onBinaryMessage(byte[] data) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onBinaryMessage([{}]) - webSocketListener:{}, listener:{}", + data.length, + (listener instanceof WebSocketListener), + this.listener.getClass().getName()); + } + if (listener instanceof WebSocketListener) { ((WebSocketListener)listener).onWebSocketBinary(data, 0, data.length); @@ -116,6 +140,11 @@ public void onClose(CloseInfo close) int statusCode = close.getStatusCode(); String reason = close.getReason(); + + if (LOG.isDebugEnabled()) + { + LOG.debug("onClose({},{}) - listener:{}", statusCode, reason, this.listener.getClass().getName()); + } listener.onWebSocketClose(statusCode, reason); } @@ -123,19 +152,34 @@ public void onClose(CloseInfo close) public void onConnect() { if (LOG.isDebugEnabled()) - LOG.debug("onConnect({})", session); + { + LOG.debug("onConnect({}) - listener:{}", session, this.listener.getClass().getName()); + } listener.onWebSocketConnect(session); } @Override public void onError(Throwable cause) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onError({}) - listener:{}", cause.getClass().getName(), this.listener.getClass().getName()); + } listener.onWebSocketError(cause); } @Override public void onFrame(Frame frame) { + if (LOG.isDebugEnabled()) + { + LOG.debug("onFrame({}) - frameListener:{}, pingPongListener:{}, listener:{}", + frame, + (listener instanceof WebSocketFrameListener), + (listener instanceof WebSocketPingPongListener), + this.listener.getClass().getName()); + } + if (listener instanceof WebSocketFrameListener) { ((WebSocketFrameListener)listener).onWebSocketFrame(new ReadOnlyDelegatedFrame(frame)); @@ -169,6 +213,16 @@ public void onReader(Reader reader) @Override public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException { + if (LOG.isDebugEnabled()) + { + LOG.debug("onTextFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + BufferUtil.toDetailString(buffer), + fin, + (listener instanceof WebSocketListener), + (listener instanceof WebSocketPartialListener), + listener.getClass().getName()); + } + if (listener instanceof WebSocketListener) { if (activeMessage == null) @@ -226,6 +280,18 @@ public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException @Override public void onTextMessage(String message) { + if (LOG.isDebugEnabled()) + { + String msgDetail = message == null + ? "" + : String.format("[%d] \"%s\"", message.length(), TextUtil.maxStringLength(60, message)); + + LOG.debug("onTextMessage({}) - webSocketListener:{} listener:{}", + msgDetail, + (listener instanceof WebSocketListener), + listener.getClass().getName()); + } + if (listener instanceof WebSocketListener) { ((WebSocketListener)listener).onWebSocketText(message); @@ -234,6 +300,15 @@ public void onTextMessage(String message) public void onContinuationFrame(ByteBuffer buffer, boolean fin) throws IOException { + if (LOG.isDebugEnabled()) + { + LOG.debug("onContinuationFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + BufferUtil.toDetailString(buffer), fin, + (listener instanceof WebSocketListener), + (listener instanceof WebSocketPartialListener), + listener.getClass().getName()); + } + if (listener instanceof WebSocketPartialListener) { switch (partialMode) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java index 0f10c71e9bd7..145ea510e964 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java @@ -139,6 +139,9 @@ public Class getPojo() @Override public String toString() { - return String.format("%s[%s]", this.getClass().getSimpleName(), method.toGenericString()); + return String.format("%s[pojo=%s,method=%s]", + this.getClass().getSimpleName(), + pojo.getName(), + method.toGenericString()); } } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/OptionalSessionCallableMethod.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/OptionalSessionCallableMethod.java index aca97a2eb01c..115a6d124172 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/OptionalSessionCallableMethod.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/OptionalSessionCallableMethod.java @@ -86,6 +86,11 @@ public boolean isStreaming() @Override public String toString() { - return String.format("%s[%s]", this.getClass().getSimpleName(), method.toGenericString()); + return String.format("%s[pojo=%s,method=%s,wantsSession=%b,streaming=%s]", + this.getClass().getSimpleName(), + pojo.getName(), + method.toGenericString(), + wantsSession, + streaming); } } From 46402bc382a0627b648b593bcf052d4fe7728211 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 28 Aug 2020 05:46:07 -0500 Subject: [PATCH 2/2] Issue #5193 - Updating logging per review Signed-off-by: Joakim Erdfelt --- .../events/JettyAnnotatedEventDriver.java | 12 +++---- .../events/JettyListenerEventDriver.java | 34 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java index 5bec0316252f..56aa8d57b97a 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyAnnotatedEventDriver.java @@ -92,7 +92,8 @@ public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException { if (LOG.isDebugEnabled()) { - LOG.debug("onBinaryFrame({}, {}) - events.onBinary={}", BufferUtil.toDetailString(buffer), fin, events.onBinary); + LOG.debug("onBinaryFrame({}, {}) - events.onBinary={}, activeMessage={}", + BufferUtil.toDetailString(buffer), fin, events.onBinary, activeMessage); } if (events.onBinary == null) @@ -254,7 +255,8 @@ public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException { if (LOG.isDebugEnabled()) { - LOG.debug("onTextFrame({}, {}) - events.onText={}", BufferUtil.toDetailString(buffer), fin, events.onText); + LOG.debug("onTextFrame({}, {}) - events.onText={}, activeMessage={}", + BufferUtil.toDetailString(buffer), fin, events.onText, activeMessage); } if (events.onText == null) @@ -303,10 +305,8 @@ public void onTextMessage(String message) { if (LOG.isDebugEnabled()) { - if (message == null) - LOG.debug("onTextMessage() - events.onText={}", events.onText); - else - LOG.debug("onTextMessage([{}] \"{}\") - events.onText={}", message.length(), TextUtil.maxStringLength(60, message), events.onText); + LOG.debug("onTextMessage([{}] \"{}\") - events.onText={}", + message.length(), TextUtil.maxStringLength(60, message), events.onText); } if (events.onText != null) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java index fcf85a1a5941..dc9ed1059c31 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java @@ -73,11 +73,12 @@ public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException { if (LOG.isDebugEnabled()) { - LOG.debug("onBinaryFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + LOG.debug("onBinaryFrame({}, {}) - webSocketListener={}, webSocketPartialListener={}, listener={}, activeMessage={}", BufferUtil.toDetailString(buffer), fin, (listener instanceof WebSocketListener), (listener instanceof WebSocketPartialListener), - listener.getClass().getName()); + listener.getClass().getName(), + activeMessage); } if (listener instanceof WebSocketListener) @@ -116,7 +117,7 @@ public void onBinaryMessage(byte[] data) { if (LOG.isDebugEnabled()) { - LOG.debug("onBinaryMessage([{}]) - webSocketListener:{}, listener:{}", + LOG.debug("onBinaryMessage([{}]) - webSocketListener={}, listener={}", data.length, (listener instanceof WebSocketListener), this.listener.getClass().getName()); @@ -143,7 +144,7 @@ public void onClose(CloseInfo close) if (LOG.isDebugEnabled()) { - LOG.debug("onClose({},{}) - listener:{}", statusCode, reason, this.listener.getClass().getName()); + LOG.debug("onClose({},{}) - listener={}", statusCode, reason, this.listener.getClass().getName()); } listener.onWebSocketClose(statusCode, reason); } @@ -153,7 +154,7 @@ public void onConnect() { if (LOG.isDebugEnabled()) { - LOG.debug("onConnect({}) - listener:{}", session, this.listener.getClass().getName()); + LOG.debug("onConnect({}) - listener={}", session, this.listener.getClass().getName()); } listener.onWebSocketConnect(session); } @@ -163,7 +164,7 @@ public void onError(Throwable cause) { if (LOG.isDebugEnabled()) { - LOG.debug("onError({}) - listener:{}", cause.getClass().getName(), this.listener.getClass().getName()); + LOG.debug("onError({}) - listener={}", cause.getClass().getName(), this.listener.getClass().getName()); } listener.onWebSocketError(cause); } @@ -173,7 +174,7 @@ public void onFrame(Frame frame) { if (LOG.isDebugEnabled()) { - LOG.debug("onFrame({}) - frameListener:{}, pingPongListener:{}, listener:{}", + LOG.debug("onFrame({}) - frameListener={}, pingPongListener={}, listener={}", frame, (listener instanceof WebSocketFrameListener), (listener instanceof WebSocketPingPongListener), @@ -215,12 +216,13 @@ public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException { if (LOG.isDebugEnabled()) { - LOG.debug("onTextFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + LOG.debug("onTextFrame({}, {}) - webSocketListener={}, webSocketPartialListener={}, listener={}, activeMessage={}", BufferUtil.toDetailString(buffer), fin, (listener instanceof WebSocketListener), (listener instanceof WebSocketPartialListener), - listener.getClass().getName()); + listener.getClass().getName(), + activeMessage); } if (listener instanceof WebSocketListener) @@ -282,12 +284,9 @@ public void onTextMessage(String message) { if (LOG.isDebugEnabled()) { - String msgDetail = message == null - ? "" - : String.format("[%d] \"%s\"", message.length(), TextUtil.maxStringLength(60, message)); - - LOG.debug("onTextMessage({}) - webSocketListener:{} listener:{}", - msgDetail, + LOG.debug("onTextMessage([{}] \"{}\") - webSocketListener={}, listener={}", + message.length(), + TextUtil.maxStringLength(60, message), (listener instanceof WebSocketListener), listener.getClass().getName()); } @@ -302,11 +301,12 @@ public void onContinuationFrame(ByteBuffer buffer, boolean fin) throws IOExcepti { if (LOG.isDebugEnabled()) { - LOG.debug("onContinuationFrame({}, {}) - webSocketListener:{}, webSocketPartialListener:{}, listener:{}", + LOG.debug("onContinuationFrame({}, {}) - webSocketListener={}, webSocketPartialListener={}, listener={}, activeMessage={}", BufferUtil.toDetailString(buffer), fin, (listener instanceof WebSocketListener), (listener instanceof WebSocketPartialListener), - listener.getClass().getName()); + listener.getClass().getName(), + activeMessage); } if (listener instanceof WebSocketPartialListener)