Skip to content

Commit

Permalink
NO-JIRA STOMP frame logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jbertram committed Jun 20, 2018
1 parent f4bb88e commit 43a95be
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,27 @@ public void handleFrame(StompFrame request) {
}
}

public void logFrame(StompFrame request, boolean in) {
if (ActiveMQStompProtocolLogger.LOGGER.isDebugEnabled()) {
StringBuilder message = new StringBuilder()
.append("STOMP(")
.append(getRemoteAddress())
.append(", ")
.append(this.getID())
.append("):");

if (in) {
message.append(" IN << ");
} else {
message.append("OUT >> ");
}

message.append(request);

ActiveMQStompProtocolLogger.LOGGER.debug(message.toString());
}
}

public void sendFrame(StompFrame frame, StompPostReceiptFunction function) {
manager.sendReply(this, frame, function);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public int getEncodedSize() throws Exception {

@Override
public String toString() {
return "StompFrame[command=" + command + ", headers=" + headers + ", content= " + this.body + " bytes " +
Arrays.toString(bytesBody);
return new StringBuilder()
.append("StompFrame[command=").append(command)
.append(", headers=").append(headers)
.append(", content= ").append(this.body)
.append(", bytes= ").append(Arrays.toString(bytesBody))
.toString();
}

public boolean isPing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void handleBuffer(final RemotingConnection connection, final ActiveMQBuff

try {
invokeInterceptors(this.incomingInterceptors, request, conn);
conn.logFrame(request, true);
conn.handleFrame(request);
} finally {
server.getStorageManager().clearContext();
Expand Down Expand Up @@ -186,11 +187,8 @@ public List<String> websocketSubprotocolIdentifiers() {
// Public --------------------------------------------------------

public boolean send(final StompConnection connection, final StompFrame frame) {
if (ActiveMQStompProtocolLogger.LOGGER.isTraceEnabled()) {
ActiveMQStompProtocolLogger.LOGGER.trace("sent " + frame);
}

invokeInterceptors(this.outgoingInterceptors, frame, connection);
connection.logFrame(frame, false);

synchronized (connection) {
if (connection.isDestroyed()) {
Expand Down

0 comments on commit 43a95be

Please sign in to comment.