summaryrefslogtreecommitdiffstats
path: root/src/transport/mycelium
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-29 01:52:37 +0100
committertv <tv@krebsco.de>2026-10-29 01:52:37 +0100
commitbc6fb7aa5281a50ff3b1ab8b1deae18e04449e31 (patch)
treee380f52f5ce0f70a46f50006ba82004ec2b684fc /src/transport/mycelium
parent22b7deb7f6ae8d353af94ef1f02bcccf2779e1c2 (diff)
log messages in paths layer
Diffstat (limited to 'src/transport/mycelium')
-rw-r--r--src/transport/mycelium/mod.rs39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs
index 5e8dc05..d33e323 100644
--- a/src/transport/mycelium/mod.rs
+++ b/src/transport/mycelium/mod.rs
@@ -246,31 +246,17 @@ impl Transport for MyceliumTransport {
.into());
}
- // Mycelium's message ID, for GET /api/v1/messages/status/{id} when chasing
- // a message that never arrived.
- if tracing::enabled!(tracing::Level::DEBUG) {
- let Ok(body) = response
+ // Mycelium's message ID, for GET /api/v1/messages/status/{id} when chasing a
+ // message that never arrived. The message itself is logged above, in the paths
+ // layer (`transport::paths`).
+ if tracing::enabled!(tracing::Level::TRACE) {
+ let id = response
.bytes()
.await
- .map_err(anyhow::Error::from)
- .and_then(|bytes| Ok(serde_json::from_slice::<serde_json::Value>(&bytes)?))
- else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), "Sent message (couldn't decode response from Mycelium REST API)");
- return Ok(());
- };
- let Ok(outbound) = serde_json::from_slice::<OutboundMessage>(&message.body) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), body_len = %message.body.len(), "Sent message (couldn't parse outbound message)");
- return Ok(());
- };
- let Ok(parsed) = decode_payload(&outbound.topic, &outbound.payload) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?outbound, "Sent message (couldn't decode outbound message)");
- return Ok(());
- };
- let Some(id) = body.get("id").and_then(|id| id.as_str()) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?parsed, "Sent message (couldn't read id from Mycelium REST API response)");
- return Ok(());
- };
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?parsed, id = %id, "Sent message");
+ .ok()
+ .and_then(|bytes| serde_json::from_slice::<serde_json::Value>(&bytes).ok())
+ .and_then(|body| body.get("id")?.as_str().map(str::to_owned));
+ tracing::trace!(to = %Addressed(SCHEME, &message.peer), id = ?id, "Mycelium took the message");
}
Ok(())
}
@@ -300,12 +286,11 @@ impl Transport for MyceliumTransport {
while let Some(inbound_message) = rx.recv().await {
match parse_message(&inbound_message) {
Ok((sender, parsed)) => {
- tracing::debug!(
+ // The message itself is logged above, in the paths layer.
+ tracing::trace!(
from = %Addressed(SCHEME, &inbound_message.src_pk),
- message = ?parsed,
id = %inbound_message.id,
- //payload_bytes = raw_bytes.len(),
- "Received message"
+ "Mycelium delivered a message"
);
let payload_len = base64_decoded_len(&inbound_message.payload);
if is_probe(&parsed) {