New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARTEMIS-1472 - PN_TRACE_FRM as System.out logging #1601
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.NETWORK_HOST; | ||
import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.PORT; | ||
import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.SCHEME; | ||
import static org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager.PN_TRACE_FRM; | ||
|
||
public class AMQPConnectionContext extends ProtonInitializable implements EventHandler { | ||
|
||
|
@@ -143,13 +144,26 @@ public SASLResult getSASLResult() { | |
} | ||
|
||
public void inputBuffer(ByteBuf buffer) { | ||
if (log.isTraceEnabled()) { | ||
ByteUtil.debugFrame(log, "Buffer Received ", buffer); | ||
if (PN_TRACE_FRM) { | ||
debugFrame(buffer); | ||
} | ||
|
||
handler.inputBuffer(buffer); | ||
} | ||
|
||
private static void debugFrame(ByteBuf byteIn) { | ||
int location = byteIn.readerIndex(); | ||
// debugging | ||
byte[] frame = new byte[byteIn.writerIndex()]; | ||
byteIn.readBytes(frame); | ||
|
||
if (PN_TRACE_FRM) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was checked already before calling the method. Ignoring that it would probably also be better done around the whole contents of the method to avoid creating the byte array but then not using it and then needing to readjust the buffer index later. |
||
log.info("Received frame \n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); | ||
} | ||
byteIn.readerIndex(location); | ||
} | ||
|
||
|
||
public void destroy() { | ||
connectionCallback.close(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,14 @@ | |
package org.apache.activemq.artemis.protocol.amqp.proton.handler; | ||
|
||
import org.apache.qpid.proton.engine.Event; | ||
import org.jboss.logging.Logger; | ||
|
||
import static org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager.PN_TRACE_FRM; | ||
|
||
public final class Events { | ||
|
||
private static final Logger logger = Logger.getLogger(Events.class); | ||
|
||
public static void dispatch(Event event, EventHandler handler) throws Exception { | ||
switch (event.getType()) { | ||
case CONNECTION_INIT: | ||
|
@@ -92,6 +97,9 @@ public static void dispatch(Event event, EventHandler handler) throws Exception | |
handler.onDelivery(event.getDelivery()); | ||
break; | ||
default: | ||
if (PN_TRACE_FRM) { | ||
logger.info("event: " + event + " not being treated"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also doesn't feel like it should be tied to having proton trace its frames to me, I'd just make this a regular trace logger. |
||
} | ||
break; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ | |
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.PooledByteBufAllocator; | ||
|
||
import static org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager.PN_TRACE_FRM; | ||
|
||
public class ProtonHandler extends ProtonInitializable { | ||
|
||
private static final Logger log = Logger.getLogger(ProtonHandler.class); | ||
|
@@ -443,7 +445,9 @@ private void dispatch() { | |
inDispatch = true; | ||
while ((ev = collector.peek()) != null) { | ||
for (EventHandler h : handlers) { | ||
if (log.isTraceEnabled()) { | ||
if (PN_TRACE_FRM) { | ||
log.info("Handling " + ev + " towards " + h); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also doesn't feel like it should be tied to having proton trace its frames to me. Given the existing trace logging I wouldn't do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is often what I need when debugging AMQP.. I wanted to have an easy easy to turn on and debug at console without having to turn trace for everything (It's a bit diefficult to do individually). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not saying you don't need it, or that they often wont be combined eventually, but I rarely ever want to turn that logging on at precisely the same time as I might turn the frame logging on. They don't even go to the same place, so I really feel they are separate and should have their own control toggles as they do currently. I also wouldn't generally use another projects magic toggle to control behaviour in this one. |
||
} else if (log.isTraceEnabled()) { | ||
log.trace("Handling " + ev + " towards " + h); | ||
} | ||
try { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't personally tie these things together, to me they are separate and just because I am asking proton to trace frames doesn't mean I want all the bytes logged. I do the former often enough, but only very rarely do the latter.
When I do the latter its sometimes by using config toggle to activate adding Nettys own byte logging debug LoggingHandler, though e.g for Qpid JMS we do also have specific toggles to activate something more like this.