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:48:10 GMT
Github user ppatierno commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1592#discussion_r145235982
  
    --- 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));
    +                  break;
    +               case CONNECT:
    +                  MqttConnectVariableHeader connectHeader = (MqttConnectVariableHeader)
message.variableHeader();
    +                  MqttConnectPayload payload = ((MqttConnectMessage)message).payload();
    +                  log.append(" name=").append(connectHeader.name())
    +                     .append(", version=").append(connectHeader.version())
    +                     .append(", hasUserName=").append(connectHeader.hasUserName())
    +                     .append(", hasPassword=").append(connectHeader.hasPassword())
    +                     .append(", isWillRetain=").append(connectHeader.isWillRetain())
    +                     .append(", isWillFlag=").append(connectHeader.isWillFlag())
    +                     .append(", isCleanSession=").append(connectHeader.isCleanSession())
    +                     .append(", keepAliveTimeSeconds=").append(connectHeader.keepAliveTimeSeconds())
    +                     .append(", clientIdentifier=").append(payload.clientIdentifier())
    +                     .append(", willTopic=").append(payload.willTopic())
    +                     .append(", willMessage=").append(payload.willMessage())
    +                     .append(", userName=").append(payload.userName());
    +                     //.append(", password=").append(payload.password());
    +                  break;
    +               case SUBSCRIBE:
    +                  for (MqttTopicSubscription sub : ((MqttSubscribeMessage) message).payload().topicSubscriptions())
{
    +                     log.append("\n\t" + sub.topicName() + " : " + sub.qualityOfService());
    +                  }
    +                  break;
    +               case SUBACK:
    +                  for (Integer qos : ((MqttSubAckMessage) message).payload().grantedQoSLevels())
{
    +                     log.append("\n\t" + qos);
    +                  }
    +                  break;
    +               case UNSUBSCRIBE:
    +                  for (String topic : ((MqttUnsubscribeMessage) message).payload().topics())
{
    +                     log.append("\n\t" + topic);
    --- End diff --
    
    As above you are right sorry !


---

Mime
View raw message