Skip to content

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Jan 12, 2026

Extend LogRecord with peer_id, channel_id, and payment_hash fields from LDK's Record struct. These structured fields are now available to custom LogWriter implementations and are automatically appended to log messages by the built-in FileWriter and LogFacadeWriter.

  • Add peer_id, channel_id, payment_hash fields to LogRecord (both uniffi and non-uniffi versions)
  • Add format_log_context() helper to format fields with truncated hex
  • Update FileWriter and LogFacadeWriter to append context to messages
  • Update UDL bindings with new LogRecord fields
  • Add unit tests for format_log_context and LogFacadeWriter

Closes #712

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 12, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tnull tnull self-requested a review January 12, 2026 13:34
Extend LogRecord with peer_id, channel_id, and payment_hash fields from
LDK's Record struct. These structured fields are now available to custom
LogWriter implementations and are automatically appended to log messages
by the built-in FileWriter and LogFacadeWriter.

- Add peer_id, channel_id, payment_hash fields to LogRecord (both uniffi
  and non-uniffi versions)
- Add format_log_context() helper to format fields with truncated hex
- Update FileWriter and LogFacadeWriter to append context to messages
- Update UDL bindings with new LogRecord fields
- Add unit tests for format_log_context and LogFacadeWriter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

One comment, otherwise looks good.

While you're at it, mind also making the change to ldk-server as well? See https://github.com/lightningdevkit/ldk-server/blob/f3eaacd327d40fc8ee3fd7f6fbaccb04fa077434/ldk-server/src/util/logger.rs#L86-L129


let log = format!(
"{} {:<5} [{}:{}] {}\n",
"{} {:<5} [{}:{}] {}{}\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just appending it plain looks a bit odd for some messages:

Persistence of ChannelMonitorUpdate id 13 completed ch:d6487d p:02d87e

Can we maybe wrap the context in parentheses or brackets?

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.

Update logging to include structured fields

3 participants