diff options
| author | Zeyla Hellyer <[email protected]> | 2017-09-30 15:50:17 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-09-30 16:08:12 -0700 |
| commit | 21e194bffc37f396f007d390170f5b60e22f5d02 (patch) | |
| tree | 5fde942e5867df1dfc13547a0bd039b648710cfe /src/client | |
| parent | Whoops (diff) | |
| download | serenity-21e194bffc37f396f007d390170f5b60e22f5d02.tar.xz serenity-21e194bffc37f396f007d390170f5b60e22f5d02.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, }; |