activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppatierno <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #1592: NO-JIRA improve MQTT protocol logging
Date Tue, 17 Oct 2017 19:31:41 GMT
Github user ppatierno commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1592#discussion_r145232049
  
    --- Diff: artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
---
    @@ -149,16 +154,52 @@ public static void logMessage(MQTTSessionState state, MqttMessage
message, boole
              if (message.fixedHeader() != null) {
                 log.append(message.fixedHeader().messageType().toString());
     
    -            if (message.variableHeader() instanceof MqttPublishVariableHeader) {
    -               log.append("(" + ((MqttPublishVariableHeader) message.variableHeader()).messageId()
+ ") " + message.fixedHeader().qosLevel());
    -            } else if (message.variableHeader() instanceof MqttMessageIdVariableHeader)
{
    +            if (message.variableHeader() instanceof MqttMessageIdVariableHeader) {
                    log.append("(" + ((MqttMessageIdVariableHeader) message.variableHeader()).messageId()
+ ")");
                 }
     
    -            if (message.fixedHeader().messageType() == MqttMessageType.SUBSCRIBE) {
    -               for (MqttTopicSubscription sub : ((MqttSubscribeMessage) message).payload().topicSubscriptions())
{
    -                  log.append("\n\t" + sub.topicName() + " : " + sub.qualityOfService());
    -               }
    +            switch (message.fixedHeader().messageType()) {
    +               case PUBLISH:
    +                  MqttPublishVariableHeader publishHeader = (MqttPublishVariableHeader)
message.variableHeader();
    +                  log.append("(" + publishHeader.packetId() + ")")
    +                     .append(" topic=" + publishHeader.topicName())
    +                     .append(", qos=" + message.fixedHeader().qosLevel())
    +                     .append(", retain=" + message.fixedHeader().isRetain())
    +                     .append(", dup=" + message.fixedHeader().isDup());
    +                     //.append(" payload=" + ((MqttPublishMessage)message).payload().toString(StandardCharsets.UTF_8));
    --- End diff --
    
    Yes I agree that is useful if you are using UTF8 encoded string as payload. Is it possible
having this logging line as configurable (disabled by default) so that people using Strings
can enable it for showing the payload.


---

Mime
View raw message