QPIDJMS-439: distinguish sessions and connections better in the protocol trace logs
authorRobbie Gemmell <robbie@apache.org>
Wed, 12 Dec 2018 17:03:06 +0000 (17:03 +0000)
committerRobbie Gemmell <robbie@apache.org>
Wed, 12 Dec 2018 17:03:06 +0000 (17:03 +0000)
qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProtocolTracer.java
qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java

index 2751a1b..98cd1b2 100644 (file)
@@ -30,25 +30,27 @@ public class AmqpProtocolTracer implements ProtocolTracer {
     public static final int DEFAULT_PAYLOAD_STRING_LIMIT = 1024;
 
     private final Logger logger;
+    private final int transportIdentifier;
     private final int payloadStringLimit;
 
-    public AmqpProtocolTracer(Logger logger) {
-        this(logger, DEFAULT_PAYLOAD_STRING_LIMIT);
+    public AmqpProtocolTracer(Logger logger, int transportIdentifier) {
+        this(logger, transportIdentifier, DEFAULT_PAYLOAD_STRING_LIMIT);
     }
 
-    public AmqpProtocolTracer(Logger logger, int payloadStringLimit) {
+    public AmqpProtocolTracer(Logger logger, int transportIdentifier, int payloadStringLimit) {
         this.logger = logger;
         this.payloadStringLimit = payloadStringLimit;
+        this.transportIdentifier = transportIdentifier;
     }
 
     @Override
     public void receivedFrame(TransportFrame transportFrame) {
-        logger.trace("RECV: {}{}", transportFrame.getBody(), formatPayload(transportFrame));
+        logger.trace("[{}:{}] RECV: {}{}", transportIdentifier, transportFrame.getChannel(), transportFrame.getBody(), formatPayload(transportFrame));
     }
 
     @Override
     public void sentFrame(TransportFrame transportFrame) {
-        logger.trace("SENT: {}{}", transportFrame.getBody(), formatPayload(transportFrame));
+        logger.trace("[{}:{}] SENT: {}{}", transportIdentifier, transportFrame.getChannel(), transportFrame.getBody(), formatPayload(transportFrame));
     }
 
     private String formatPayload(TransportFrame frame) {
index dbdc977..f5d1ab4 100644 (file)
@@ -785,7 +785,7 @@ public class AmqpProvider implements Provider, TransportListener , AmqpResourceP
 
     private void updateTracer() {
         if (isTraceFrames()) {
-            ((TransportImpl) protonTransport).setProtocolTracer(new AmqpProtocolTracer(TRACE_FRAMES, traceFramesPayloadLimit));
+            ((TransportImpl) protonTransport).setProtocolTracer(new AmqpProtocolTracer(TRACE_FRAMES, System.identityHashCode(protonTransport), traceFramesPayloadLimit));
         }
     }