Skip to content
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

Better Log Messages #152

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/HiveMQtt/Client/HiveMQClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public async Task<bool> DisconnectAsync(DisconnectOptions? options = null)
{
if (this.ConnectState != ConnectState.Connected)
{
Logger.Warn("DisconnectAsync: Client is not connected.");
Logger.Warn("DisconnectAsync called but this client is not connected. State is ${this.ConnectState}.");
return false;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ public async Task<SubscribeResult> SubscribeAsync(SubscribeOptions options)
}
catch (TimeoutException)
{
Logger.Error("Subscribe timeout. No response received in time.");
Logger.Error("Subscribe timeout. No SUBACK response received in time.");
throw;
}
finally
Expand Down
4 changes: 2 additions & 2 deletions Source/HiveMQtt/Client/HiveMQClientOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ public HiveMQClientOptionsBuilder WithClientCertificate(string clientCertificate
}
catch (UnauthorizedAccessException)
{
Logger.Error("File exists but is not readable due to access permissions.");
Logger.Error("WithClientCertificate: File exists but is not readable due to access permissions.");
throw;
}
catch (IOException)
{
Logger.Error("An I/O error occurred while trying to read the file.");
Logger.Error("WithClientCertificate: An I/O error occurred while trying to read the file.");
throw;
}
}
Expand Down
11 changes: 7 additions & 4 deletions Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private Task<bool> ConnectionWriterAsync(CancellationToken cancellationToken) =>
// QoS > 0 - Add to transaction queue
if (this.transactionQueue.TryAdd(publishPacket.PacketIdentifier, new List<ControlPacket> { publishPacket }) == false)
{
Logger.Warn("Duplicate packet ID detected.");
Logger.Warn($"Duplicate packet ID detected {publishPacket.PacketIdentifier} while queueing to transaction queue for an outgoing QoS {publishPacket.Message.QoS} publish .");
continue;
}
}
Expand Down Expand Up @@ -334,8 +334,8 @@ private Task<bool> ReceivedPacketsHandlerAsync(CancellationToken cancellationTok
{
if (packet.PacketSize > this.Options.ClientMaximumPacketSize)
{
Logger.Warn($"Packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
Logger.Debug($"{this.Options.ClientId}-(RPH)- Packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
Logger.Warn($"Received packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");
Logger.Debug($"{this.Options.ClientId}-(RPH)- Received packet size {packet.PacketSize} exceeds maximum packet size {this.Options.ClientMaximumPacketSize}. Disconnecting.");

var opts = new DisconnectOptions
{
Expand Down Expand Up @@ -411,6 +411,9 @@ internal void HandleIncomingPublishPacket(PublishPacket publishPacket)
{
// We've received a QoS 1 publish. Send a PubAck.
var pubAckResponse = new PubAckPacket(publishPacket.PacketIdentifier, PubAckReasonCode.Success);

// FIXME We should wait until puback is sent before launching event
// FIXME Check DUP flag setting
this.SendQueue.Add(pubAckResponse);
}
else if (publishPacket.Message.QoS is MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
Expand All @@ -421,7 +424,7 @@ internal void HandleIncomingPublishPacket(PublishPacket publishPacket)

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

Expand Down
Loading