diff options
| author | Zeyla Hellyer <[email protected]> | 2017-09-30 15:50:17 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-10-09 15:45:48 -0700 |
| commit | f0ee805a8ee20b6180b9f54d5096a8a9b73b4be2 (patch) | |
| tree | 47dcc937ae51fd4082bd9d88aca809d9e73fb4f8 /src/client | |
| parent | Whoops (diff) | |
| download | serenity-f0ee805a8ee20b6180b9f54d5096a8a9b73b4be2.tar.xz serenity-f0ee805a8ee20b6180b9f54d5096a8a9b73b4be2.zip | |
Improve shard and shard runner logging
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/bridge/gateway/shard_runner.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/client/bridge/gateway/shard_runner.rs b/src/client/bridge/gateway/shard_runner.rs index d99cf76..530e367 100644 --- a/src/client/bridge/gateway/shard_runner.rs +++ b/src/client/bridge/gateway/shard_runner.rs @@ -23,6 +23,7 @@ pub struct ShardRunner<H: EventHandler + 'static> { runner_rx: Receiver<ShardManagerMessage>, runner_tx: Sender<ShardManagerMessage>, shard: LockedShard, + shard_info: [u64; 2], } impl<H: EventHandler + 'static> ShardRunner<H> { @@ -33,6 +34,7 @@ impl<H: EventHandler + 'static> ShardRunner<H> { data: Arc<ParkingLotMutex<ShareMap>>, event_handler: Arc<H>) -> Self { let (tx, rx) = mpsc::channel(); + let shard_info = shard.lock().shard_info(); Self { runner_rx: rx, @@ -42,6 +44,7 @@ impl<H: EventHandler + 'static> ShardRunner<H> { framework, manager_tx, shard, + shard_info, } } @@ -51,6 +54,7 @@ impl<H: EventHandler + 'static> ShardRunner<H> { data: Arc<ParkingLotMutex<ShareMap>>, event_handler: Arc<H>) -> Self { let (tx, rx) = mpsc::channel(); + let shard_info = shard.lock().shard_info(); Self { runner_rx: rx, @@ -59,10 +63,13 @@ impl<H: EventHandler + 'static> ShardRunner<H> { event_handler, manager_tx, shard, + shard_info, } } pub fn run(&mut self) -> Result<()> { + debug!("[ShardRunner {:?}] Running", self.shard_info); + loop { { let mut shard = self.shard.lock(); @@ -146,15 +153,24 @@ impl<H: EventHandler + 'static> ShardRunner<H> { break; } - debug!("Attempting to auto-reconnect"); + debug!("[ShardRunner {:?}] Attempting to auto-reconnect", + self.shard_info); if let Err(why) = shard.autoreconnect() { - error!("Failed to auto-reconnect: {:?}", why); + error!( + "[ShardRunner {:?}] Failed to auto-reconnect: {:?}", + self.shard_info, + why, + ); } break; }, - Err(Error::WebSocket(WebSocketError::NoDataAvailable)) => break, + Err(Error::WebSocket(WebSocketError::NoDataAvailable)) => { + // This is hit when the websocket client dies this will be + // hit every iteration. + break; + }, other => other, }; |