Skip to content

Commit

Permalink
pool: better logs
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Dec 2, 2024
1 parent b74131d commit 1cae800
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions crates/nostr-relay-pool/src/relay/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl InnerRelay {
// Set ping as just sent
ping.just_sent().await;

tracing::debug!("Ping '{}' (nonce: {nonce})", self.url);
tracing::trace!("Ping '{}' (nonce: {nonce})", self.url);
}
}
else => break
Expand Down Expand Up @@ -763,7 +763,7 @@ impl InnerRelay {
break;
}

tracing::debug!(
tracing::trace!(
"Pong from '{}' match nonce: {nonce}",
self.url
);
Expand Down Expand Up @@ -843,21 +843,38 @@ impl InnerRelay {
status,
message,
} => {
tracing::debug!("Received OK from '{}' for event {event_id}: status={status}, message={message}", self.url);
tracing::debug!(
url = %self.url,
id = %event_id,
status = %status,
msg = %message,
"Received OK."
);
}
RelayMessage::EndOfStoredEvents(id) => {
tracing::debug!(
url = %self.url,
id = %id,
"Received EOSE."
);
}
RelayMessage::Closed {
subscription_id, ..
subscription_id,
message,
} => {
tracing::debug!(
"Subscription '{subscription_id}' closed by '{}'",
self.url
url = %self.url,
id = %subscription_id,
msg = %message,
"Subscription closed."
);
self.subscription_closed(subscription_id).await;
}
RelayMessage::Auth { challenge } => {
tracing::debug!(
"Received '{challenge}' authentication challenge from '{}'",
self.url
url = %self.url,
challenge = %challenge,
"Received AUTH challenge."
);

// Check if NIP42 auto authentication is enabled
Expand All @@ -873,13 +890,14 @@ impl InnerRelay {
false,
);

tracing::info!("Authenticated to '{}' relay.", relay.url);
tracing::info!(url = %relay.url, "Authenticated to relay.");

// TODO: ?
if let Err(e) = relay.resubscribe().await {
tracing::error!(
"Impossible to resubscribe to '{}': {e}",
relay.url
url = %relay.url,
error = %e,
"Impossible to resubscribe."
);
}
}
Expand All @@ -890,8 +908,9 @@ impl InnerRelay {
);

tracing::error!(
"Can't authenticate to '{}' relay: {e}",
relay.url
url = %relay.url,
error = %e,
"Can't authenticate to relay."
);
}
}
Expand Down Expand Up @@ -1461,7 +1480,7 @@ impl InnerRelay {
// Unsubscribe
this.send_msg(ClientMessage::close(sub_id.clone()))?;

tracing::debug!("Subscription {sub_id} auto-closed");
tracing::debug!(id = %sub_id, "Subscription auto-closed.");
}

Ok::<(), Error>(())
Expand Down

0 comments on commit 1cae800

Please sign in to comment.