You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.LogInfo("Message with messageid %s along with callback and callbackcontext is added to the queue, method name is %s ", message.getMessageId(), logger.getMethodName());
254
258
// Codes_SRS_DEVICECLIENT_11_006: [The function shall add the message, with its associated callback and callback context, to the transport.]
Copy file name to clipboardExpand all lines: device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/DeviceClientConfig.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ public final class DeviceClientConfig
40
40
/** The context to be passed in to the message callback. */
41
41
protectedObjectmessageContext;
42
42
43
+
protectedCustomLoggerlogger;
43
44
/**
44
45
* Constructor.
45
46
*
@@ -79,7 +80,8 @@ public DeviceClientConfig(String iotHubHostname, String deviceId,
79
80
this.deviceKey = deviceKey;
80
81
// Codes_SRS_DEVICECLIENTCONFIG_25_017: [**The constructor shall save sharedAccessToken.**] **
81
82
this.sharedAccessToken = sharedAccessToken;
82
-
83
+
this.logger = newCustomLogger(this.getClass());
84
+
logger.LogInfo("DeviceClientConfig object is created successfully with IotHubName=%s, deviceID=%s , method name is %s ", this.iotHubName, this.deviceId, logger.getMethodName());
@@ -372,6 +373,6 @@ public void setExpiryTime(long timeOut)
372
373
{
373
374
longcurrentTime = System.currentTimeMillis();
374
375
this.expiryTime = currentTime + timeOut;
375
-
logger.LogInfo("The message with messageid %s has expiry time as %s, method name is %s ", this.getMessageId(), newDate(this.expiryTime), logger.getMethodName());
376
+
logger.LogInfo("The message with messageid %s has expiry time as %s milliseconds and the message will expire on %s, method name is %s ", this.getMessageId(), timeOut, newDate(this.expiryTime), logger.getMethodName());
Copy file name to clipboardExpand all lines: device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/MessageProperty.java
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ public final class MessageProperty {
41
41
protectedfinalStringname;
42
42
/** The property value. */
43
43
protectedfinalStringvalue;
44
-
44
+
protectedCustomLoggerlogger;
45
45
/**
46
46
* Constructor.
47
47
*
@@ -54,29 +54,35 @@ public final class MessageProperty {
54
54
* A message property name cannot be one of the reserved property names.
55
55
*/
56
56
publicMessageProperty(Stringname, Stringvalue) {
57
+
this.logger = newCustomLogger(this.getClass());
57
58
if (name == null) {
59
+
logger.LogError("Property argument 'name' cannot be null, method name is %s ", logger.getMethodName());
58
60
thrownewIllegalArgumentException("Property argument 'name' cannot be null.");
59
61
}
60
62
61
63
if (value == null) {
64
+
logger.LogError("Property argument 'value' cannot be null, method name is %s ", logger.getMethodName());
62
65
thrownewIllegalArgumentException("Property argument 'value' cannot be null.");
63
66
}
64
67
65
68
// Codes_SRS_MESSAGEPROPERTY_11_002: [If the name contains a character that is not in US-ASCII printable characters or is one of: ()<>@,;:\"/[]?={} (space) (horizontal tab), the function shall throw an IllegalArgumentException.]
66
69
if (!usesValidChars(name)) {
67
-
StringerrMsg = String.format("%s is not a valid IoT Hub message property name.\n", name);
70
+
logger.LogError("%s is not a valid IoT Hub message property name, method name is %s ", name, logger.getMethodName());
71
+
StringerrMsg = String.format("%s is not a valid IoT Hub message property name.\n", name);
68
72
thrownewIllegalArgumentException(errMsg);
69
73
}
70
74
71
75
// Codes_SRS_MESSAGEPROPERTY_11_008: [If the name is a reserved property name, the function shall throw an IllegalArgumentException.]
72
76
if (RESERVED_PROPERTY_NAMES.contains(name)) {
73
-
StringerrMsg = String.format("%s is a reserved IoT Hub message property name.\n", name);
77
+
logger.LogError("%s is a reserved IoT Hub message property name, method name is %s ", name, logger.getMethodName());
78
+
StringerrMsg = String.format("%s is a reserved IoT Hub message property name.\n", name);
74
79
thrownewIllegalArgumentException(errMsg);
75
80
}
76
81
77
82
// Codes_SRS_MESSAGEPROPERTY_11_003: [If the value contains a character that is not in US-ASCII printable characters or is one of: ()<>@,;:\"/[]?={} (space) (horizontal tab), the function shall throw an IllegalArgumentException.]
78
83
if (!usesValidChars(value))
79
84
{
85
+
logger.LogError("%s is a reserved IoT Hub message property name, method name is %s ", name, logger.getMethodName());
80
86
StringerrMsg = String.format("%s is not a valid IoT Hub message property value.\n", value);
Copy file name to clipboardExpand all lines: device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/amqps/AmqpsIotHubConnection.java
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -337,11 +337,13 @@ public Integer sendMessage(Message message)
337
337
byte[] msgData = newbyte[1024];
338
338
intlength;
339
339
340
+
logger.LogInfo("Started encoding of message - entering in while loop, method name is %s ", logger.getMethodName());
logger.LogInfo("Completed encoding of message, length is %s - breaking the while loop to come out, method name is %s ", length, logger.getMethodName());
345
347
break;
346
348
}
347
349
catch (BufferOverflowExceptione)
@@ -354,15 +356,17 @@ public Integer sendMessage(Message message)
354
356
byte[] tag = String.valueOf(this. nextTag++).getBytes();
355
357
Deliverydlv = sender.delivery(tag);
356
358
359
+
logger.LogInfo("Attempting to send the message using the sender link, method name is %s ", logger.getMethodName());
357
360
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_018: [The function shall attempt to send the message using the sender link.]
358
361
sender.send(msgData, 0, length);
359
-
362
+
363
+
logger.LogInfo("Advancing the sender link, method name is %s ", logger.getMethodName());
360
364
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_019: [The function shall advance the sender link.]
361
365
sender.advance();
362
366
363
367
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_020: [The function shall set the delivery hash to the value returned by the sender link.]
364
368
deliveryHash = dlv.hashCode();
365
-
369
+
logger.LogInfo("Delivery hash returned by the sender link %s, method name is %s ", deliveryHash, logger.getMethodName());
366
370
}
367
371
368
372
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_021: [The function shall return the delivery hash.]
@@ -384,6 +388,7 @@ public Boolean sendMessageResult(AmqpsMessage message, IotHubMessageResult resul
384
388
{
385
389
try
386
390
{
391
+
logger.LogInfo("Acknowledgement for received message is %s, method name is %s ", result.name(), logger.getMethodName());
387
392
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_023: [If the message result is COMPLETE, ABANDON, or REJECT,
388
393
// the function shall acknowledge the last message with acknowledgement type COMPLETE, ABANDON, or REJECT respectively.]
389
394
switch (result)
@@ -399,6 +404,7 @@ public Boolean sendMessageResult(AmqpsMessage message, IotHubMessageResult resul
399
404
break;
400
405
default:
401
406
// should never happen.
407
+
logger.LogError("Invalid IoT Hub message result (%s), method name is %s ", result.name(), logger.getMethodName());
@@ -545,23 +551,26 @@ public void onDelivery(Event event)
545
551
logger.LogDebug("Entered in method %s", logger.getMethodName());
546
552
if(event.getLink().getName().equals(receiveTag))
547
553
{
554
+
logger.LogInfo("Reading the receiver link, method name is %s ", logger.getMethodName());
548
555
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_034: [If this link is the Receiver link, the event handler shall get the Receiver and Delivery (Proton) objects from the event.]
549
556
ReceiverreceiveLink = (Receiver) event.getLink();
550
557
Deliverydelivery = receiveLink.current();
551
558
if (delivery.isReadable() && !delivery.isPartial()) {
559
+
logger.LogInfo("Reading the received buffer, method name is %s ", logger.getMethodName());
552
560
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_035: [The event handler shall read the received buffer.]
logger.LogInfo("Reading the received buffer completed, method name is %s ", logger.getMethodName());
558
566
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_036: [The event handler shall create an AmqpsMessage object from the decoded buffer.]
559
567
AmqpsMessagemsg = newAmqpsMessage();
560
568
561
569
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_037: [The event handler shall set the AmqpsMessage Deliver (Proton) object.]
562
570
msg.setDelivery(delivery);
571
+
logger.LogInfo("Decoding the received message , method name is %s ", logger.getMethodName());
563
572
msg.decode(buffer, 0, read);
564
-
573
+
logger.LogInfo("Decoding the received message completed , method name is %s ", logger.getMethodName());
565
574
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_049: [All the listeners shall be notified that a message was received from the server.]
566
575
this.messageReceivedFromServer(msg);
567
576
}
@@ -571,12 +580,15 @@ public void onDelivery(Event event)
571
580
//Sender specific section for dispositions it receives
572
581
if(event.getType() == Event.Type.DELIVERY)
573
582
{
583
+
logger.LogInfo("Reading the delivery event in Sender link, method name is %s ", logger.getMethodName());
574
584
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_038: [If this link is the Sender link and the event type is DELIVERY, the event handler shall get the Delivery (Proton) object from the event.]
575
585
Deliveryd = event.getDelivery();
576
586
DeliveryStateremoteState = d.getRemoteState();
577
587
578
588
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_039: [The event handler shall note the remote delivery state and use it and the Delivery (Proton) hash code to inform the AmqpsIotHubConnection of the message receipt.]
0 commit comments