Use tracing's macros for debug/display; enable dataspace debug

This commit is contained in:
Tony Garnock-Jones 2021-08-30 12:01:47 +02:00
parent c0b73d3efa
commit 633b83412e
4 changed files with 15 additions and 15 deletions

View File

@ -511,12 +511,12 @@ impl FacetRef {
state);
for action in std::mem::take(&mut t.state.exit_hooks) {
if let Err(err) = action(&mut t, &exit_status) {
tracing::error!(err = debug(err), "error in exit hook");
tracing::error!(?err, "error in exit hook");
}
}
if let Err(err) = t._terminate_facet(t.state.root, false) {
// This can only occur as the result of an internal error in this file's code.
tracing::error!(err = debug(err), "unexpected error from disorderly terminate_facet");
tracing::error!(?err, "unexpected error from disorderly terminate_facet");
panic!("Unexpected error result from disorderly terminate_facet");
}
*g = ActorState::Terminated {
@ -1342,12 +1342,12 @@ impl Drop for Facet {
{
let mut b = EventBuffer::new(Account::new(crate::name!("drop")));
for (_handle, r) in to_clear.into_iter() {
tracing::trace!(h = debug(&_handle), "retract on termination");
tracing::trace!(h = ?_handle, "retract on termination");
b.execute_cleanup_action(r);
}
}
tracing::trace!(facet_id = debug(self.facet_id), "Facet::drop");
tracing::trace!(facet_id = ?self.facet_id, "Facet::drop");
}
}

View File

@ -92,7 +92,7 @@ impl Dataspace {
impl Entity<_Any> for Dataspace {
fn assert(&mut self, t: &mut Activation, a: _Any, h: Handle) -> ActorResult {
// tracing::trace!(assertion = debug(&a), handle = debug(&h), "assert");
tracing::trace!(assertion = ?a, handle = ?h, "assert");
// let old_assertions = self.index.assertion_count();
self.index.insert(t, &a);
@ -110,7 +110,7 @@ impl Entity<_Any> for Dataspace {
}
fn retract(&mut self, t: &mut Activation, h: Handle) -> ActorResult {
// tracing::trace!(handle = debug(&h), "retract");
tracing::trace!(handle = ?h, "retract");
if let Some((a, maybe_o)) = self.handle_map.remove(&h) {
if let Some(o) = maybe_o {
@ -127,7 +127,7 @@ impl Entity<_Any> for Dataspace {
}
fn message(&mut self, t: &mut Activation, m: _Any) -> ActorResult {
// tracing::trace!(body = debug(&m), "message");
tracing::trace!(body = ?m, "message");
// self.index.send(t, &m, &mut self.churn.messages_delivered);
self.index.send(t, &m);

View File

@ -252,11 +252,11 @@ impl TunnelRelay {
}
fn handle_inbound_packet(&mut self, t: &mut Activation, p: P::Packet) -> ActorResult {
// tracing::trace!(packet = debug(&p), "-->");
// tracing::trace!(packet = ?p, "-->");
match p {
P::Packet::Error(b) => {
tracing::info!(message = debug(b.message.clone()),
detail = debug(b.detail.clone()),
tracing::info!(message = ?b.message.clone(),
detail = ?b.detail.clone(),
"received Error from peer");
Err(*b)
},
@ -372,7 +372,7 @@ impl TunnelRelay {
fn encode_packet(&mut self, p: P::Packet) -> Result<Vec<u8>, Error> {
let item = AnyValue::from(&p);
// tracing::trace!(packet = debug(&item), "<--");
// tracing::trace!(packet = ?item, "<--");
if self.output_text {
let mut s = TextWriter::encode::<_, AnyValue, _>(&mut self.membranes, &item)?;
s.push('\n');

View File

@ -21,22 +21,22 @@ pub fn tracer<M: Debug>(t: &mut Activation, name: tracing::Span) -> Arc<Ref<M>>
impl<M: Debug> Entity<M> for Tracer {
fn assert(&mut self, _t: &mut Activation, a: M, h: Handle) -> ActorResult {
let _guard = self.0.enter();
tracing::trace!(a = debug(&a), h = debug(&h), "assert");
tracing::trace!(?a, ?h, "assert");
Ok(())
}
fn retract(&mut self, _t: &mut Activation, h: Handle) -> ActorResult {
let _guard = self.0.enter();
tracing::trace!(h = debug(&h), "retract");
tracing::trace!(?h, "retract");
Ok(())
}
fn message(&mut self, _t: &mut Activation, m: M) -> ActorResult {
let _guard = self.0.enter();
tracing::trace!(m = debug(&m), "message");
tracing::trace!(?m, "message");
Ok(())
}
fn sync(&mut self, t: &mut Activation, peer: Arc<Ref<Synced>>) -> ActorResult {
let _guard = self.0.enter();
tracing::trace!(peer = debug(&peer), "sync");
tracing::trace!(?peer, "sync");
t.message(&peer, Synced);
Ok(())
}