Skip to content

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Nov 6, 2025

Try out to see how tracing can be used instead of the current Logger. Advantages:

  • No more logger to pass around
  • No more L: Deref, L::Target:Logger generics
  • Using spans to get more insights in execution flow, using standard tools
  • Adding data fields to spans without requiring a specific With...Logger instance

To keep apart test logs in multi-node tests, a proc macro is used to automatically enter a node specific span at the beginning of each public function.

@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

// tracing_subscriber::fmt()
// // .with_span_list(true) // <--- print parent span chain
// .with_span_events(FmtSpan::FULL)
// .init();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default trace output, useful to see what's all that we have.

}

fn do_test_keysend_payments(public_node: bool) {
let layer = TestTracerLayer {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Configure layer that produces TestLogger like output with a node id.

}

/// A tracing `Layer` that forwards tracing events to a given `Logger`.
pub struct TracingToLogger<L: Deref>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently unused, but demonstrates how we can stay backwards compatible with a Logger impl.

macro_rules! log_info {
($logger: expr, $($arg:tt)*) => (
$crate::log_given_level!($logger, $crate::util::logger::Level::Info, $($arg)*);
tracing::info!($($arg)*);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No logger instance needed....

tracing::Level::TRACE => "TRACE",
};

let context = format!(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestLogger compatible output.

let mut current = Some(span);
while let Some(s) = current {
let extensions = s.extensions();
if let Some(info) = extensions.get::<NodeInfo>() {
Copy link
Contributor Author

@joostjager joostjager Nov 6, 2025

Choose a reason for hiding this comment

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

Don't ask too many questions about how this code is getting the node id.... Testing only...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants