Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gets rid of prints and anyhows on the lib #21

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

sr-gi
Copy link
Member

@sr-gi sr-gi commented Aug 16, 2023

Lets now use prints nor anyhows to bubble up errors :)

Close #24

@sr-gi sr-gi force-pushed the errors_and_logs branch 5 times, most recently from d208486 to 6a57796 Compare August 16, 2023 16:15
@@ -27,11 +36,13 @@ async fn main() -> anyhow::Result<()> {
let lnd = LndNode::new(node.address, node.macaroon, node.cert).await?;

let node_info = lnd.get_info().await?;
println!("Node info {:?}", node_info);
log::info!("Node info: {}", node_info);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should have more user-friends logs here:

Node info: Node info: { alias: alice, node_id: 0257956239efc55dd6be91eff40c47749314ccf79cb15f79e30ca12f8622b6de9e }

vs

Connected to Alice - Node ID: 0257956239efc55dd6be91eff40c47749314ccf79cb15f79e30ca12f8622b6de9e.

@@ -219,7 +250,7 @@ async fn produce_events(act: ActivityDefinition, sender: Sender<NodeAction>, shu

loop {
if time::timeout(interval, shutdown.clone()).await.is_ok() {
println!("Received shutting down signal. Shutting down");
log::info!("Received shutting down signal. Shutting down");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here, let's add debug logs for the start/ stop of this producer.

Started producer for activity.amt: activity.source -> activity.dest
Stopped producer for activity.amt: activity.source -> activity.dest: Received shutdown signal.

}
}

// consume_events processes events that are crated for a lightning node that we can execute actions on. If it exits,
// it will use the trigger provided to trigger shutdown in other threads. If an error occurs elsewhere, we expect the
// senders corresponding to our receiver to be dropped, which will cause the receiver to error out and exit.
async fn consume_events(
node_id: PublicKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for producer, let's start/stop logging for consumer. Future debugging selves will thank us.

)
}
Err(e) => {
log::error!("{}", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log details of the node / payment hash that have errored so that it can be identified when we exit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can log the node details, but we won't have the payment hash, that's only available in the Ok branch

Needed to modify consume_events in order to properly log the source and dest of the payments
@carlaKC carlaKC merged commit dc44266 into bitcoin-dev-project:main Aug 17, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nit: Log More Payment Information
2 participants