Skip to content

Commit 6158c9b

Browse files
authored
Better Log Messages (#152)
1 parent af79b77 commit 6158c9b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Source/HiveMQtt/Client/HiveMQClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public async Task<bool> DisconnectAsync(DisconnectOptions? options = null)
137137
{
138138
if (this.ConnectState != ConnectState.Connected)
139139
{
140-
Logger.Warn("DisconnectAsync: Client is not connected.");
140+
Logger.Warn("DisconnectAsync called but this client is not connected. State is ${this.ConnectState}.");
141141
return false;
142142
}
143143

@@ -343,7 +343,7 @@ public async Task<SubscribeResult> SubscribeAsync(SubscribeOptions options)
343343
}
344344
catch (TimeoutException)
345345
{
346-
Logger.Error("Subscribe timeout. No response received in time.");
346+
Logger.Error("Subscribe timeout. No SUBACK response received in time.");
347347
throw;
348348
}
349349
finally

Source/HiveMQtt/Client/HiveMQClientOptionsBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ public HiveMQClientOptionsBuilder WithClientCertificate(string clientCertificate
181181
}
182182
catch (UnauthorizedAccessException)
183183
{
184-
Logger.Error("File exists but is not readable due to access permissions.");
184+
Logger.Error("WithClientCertificate: File exists but is not readable due to access permissions.");
185185
throw;
186186
}
187187
catch (IOException)
188188
{
189-
Logger.Error("An I/O error occurred while trying to read the file.");
189+
Logger.Error("WithClientCertificate: An I/O error occurred while trying to read the file.");
190190
throw;
191191
}
192192
}

Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private Task<bool> ConnectionWriterAsync(CancellationToken cancellationToken) =>
146146
// QoS > 0 - Add to transaction queue
147147
if (this.transactionQueue.TryAdd(publishPacket.PacketIdentifier, new List<ControlPacket> { publishPacket }) == false)
148148
{
149-
Logger.Warn("Duplicate packet ID detected.");
149+
Logger.Warn($"Duplicate packet ID detected {publishPacket.PacketIdentifier} while queueing to transaction queue for an outgoing QoS {publishPacket.Message.QoS} publish .");
150150
continue;
151151
}
152152
}
@@ -334,8 +334,8 @@ private Task<bool> ReceivedPacketsHandlerAsync(CancellationToken cancellationTok
334334
{
335335
if (packet.PacketSize > this.Options.ClientMaximumPacketSize)
336336
{
337-
Logger.Warn($"Packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
338-
Logger.Debug($"{this.Options.ClientId}-(RPH)- Packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
337+
Logger.Warn($"Received packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
338+
Logger.Debug($"{this.Options.ClientId}-(RPH)- Received packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
339339

340340
var opts = new DisconnectOptions
341341
{
@@ -411,6 +411,9 @@ internal void HandleIncomingPublishPacket(PublishPacket publishPacket)
411411
{
412412
// We've received a QoS 1 publish. Send a PubAck.
413413
var pubAckResponse = new PubAckPacket(publishPacket.PacketIdentifier, PubAckReasonCode.Success);
414+
415+
// FIXME We should wait until puback is sent before launching event
416+
// FIXME Check DUP flag setting
414417
this.SendQueue.Add(pubAckResponse);
415418
}
416419
else if (publishPacket.Message.QoS is MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
@@ -421,7 +424,7 @@ internal void HandleIncomingPublishPacket(PublishPacket publishPacket)
421424

422425
if (this.transactionQueue.TryAdd(publishPacket.PacketIdentifier, publishQoS2Chain) == false)
423426
{
424-
Logger.Warn("QoS2: Duplicate packet ID detected.");
427+
Logger.Warn($"Duplicate packet ID detected {publishPacket.PacketIdentifier} while queueing to transaction queue for an incoming QoS {publishPacket.Message.QoS} publish .");
425428
pubRecResponse.ReasonCode = PubRecReasonCode.PacketIdentifierInUse;
426429
}
427430

0 commit comments

Comments
 (0)