-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
d208486
to
6a57796
Compare
sim-cli/src/main.rs
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
sim-lib/src/lib.rs
Outdated
@@ -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"); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
sim-lib/src/lib.rs
Outdated
) | ||
} | ||
Err(e) => { | ||
log::error!("{}", e); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Lets now use prints nor anyhows to bubble up errors :)
Close #24