diff --git a/Myriad/Gateway/Shard.cs b/Myriad/Gateway/Shard.cs index f52c82de..b4804585 100644 --- a/Myriad/Gateway/Shard.cs +++ b/Myriad/Gateway/Shard.cs @@ -64,7 +64,7 @@ public class Shard HeartbeatReceived?.Invoke(latency); }; - _conn = new ShardConnection(_jsonSerializerOptions, _logger); + _conn = new ShardConnection(_jsonSerializerOptions, _logger, info.ShardId); } private async Task ShardLoop() diff --git a/Myriad/Gateway/ShardConnection.cs b/Myriad/Gateway/ShardConnection.cs index 5ae4e7e1..2d62b8b1 100644 --- a/Myriad/Gateway/ShardConnection.cs +++ b/Myriad/Gateway/ShardConnection.cs @@ -11,10 +11,13 @@ public class ShardConnection: IAsyncDisposable private readonly ShardPacketSerializer _serializer; private ClientWebSocket? _client; - public ShardConnection(JsonSerializerOptions jsonSerializerOptions, ILogger logger) + private int _id; + + public ShardConnection(JsonSerializerOptions jsonSerializerOptions, ILogger logger, int id) { _logger = logger.ForContext(); _serializer = new ShardPacketSerializer(jsonSerializerOptions); + _id = id; } public WebSocketState State => _client?.State ?? WebSocketState.Closed; @@ -52,7 +55,7 @@ public class ShardConnection: IAsyncDisposable } catch (Exception e) { - _logger.Error(e, "Error sending WebSocket message"); + _logger.Error(e, "Shard {ShardId}: Error sending WebSocket message"); } } @@ -69,7 +72,7 @@ public class ShardConnection: IAsyncDisposable } catch (Exception e) { - _logger.Error(e, "Error reading from WebSocket"); + _logger.Error(e, "Shard {ShardId}: Error reading from WebSocket"); // force close so we can "reset" await CloseInner(WebSocketCloseStatus.NormalClosure, null); } @@ -98,7 +101,7 @@ public class ShardConnection: IAsyncDisposable } catch (Exception e) { - _logger.Error(e, "Error closing WebSocket connection"); + _logger.Error(e, "Shard {ShardId}: Error closing WebSocket connection"); } } @@ -109,7 +112,7 @@ public class ShardConnection: IAsyncDisposable } catch (Exception e) { - _logger.Error(e, "Error disposing WebSocket connection"); + _logger.Error(e, "Shard {ShardId}: Error disposing WebSocket connection"); } } } \ No newline at end of file