From 9bd838aa30fb63e21f94f21327e3164666b3880b Mon Sep 17 00:00:00 2001 From: Matthieu Le brazidec Date: Wed, 13 Nov 2019 01:39:39 +0100 Subject: [PATCH] Added logs to BastionContext. --- bastion/src/context.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bastion/src/context.rs b/bastion/src/context.rs index c2351a14..debdcd97 100644 --- a/bastion/src/context.rs +++ b/bastion/src/context.rs @@ -103,6 +103,7 @@ impl BastionContext { supervisor: Option, state: Qutex, ) -> Self { + debug!("BastionContext({}): Creating.", id); BastionContext { id, child, @@ -275,10 +276,17 @@ impl BastionContext { /// [`recv`]: #method.recv /// [`Msg`]: children/struct.Msg.html pub async fn try_recv(&self) -> Option { + debug!("BastionContext({}): Trying to receive message.", self.id); // TODO: Err(Error) let mut state = self.state.clone().lock_async().await.ok()?; - state.msgs.pop_front() + if let Some(msg) = state.msgs.pop_front() { + trace!("BastionContext({}): Received message: {:?}", msg); + Some(msg) + } else { + trace!("BastionContext({}): Received no message."); + None + } } /// Retrieves asynchronously a message received by the element @@ -319,11 +327,13 @@ impl BastionContext { /// [`try_recv`]: #method.try_recv /// [`Msg`]: children/struct.Msg.html pub async fn recv(&self) -> Result { + debug!("BastionContext({}): Waiting to receive message.", self.id); loop { // TODO: Err(Error) let mut state = self.state.clone().lock_async().await.unwrap(); if let Some(msg) = state.msgs.pop_front() { + trace!("BastionContext({}): Received message: {:?}", msg); return Ok(msg); }