Skip to content

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Nov 11, 2025

This PR improves channel ID logging consistency and clarity.

  • Removes redundant channel ID text from log messages where the ID is
    already included as a structured field. This reduces duplication and makes
    it easier to filter logs by channel.

  • Updates the test logger to display the structured channel ID instead of
    relying on message text. The logged ID is truncated for readability.

Together, these changes standardize how channel IDs appear in logs and make
them easier to parse and analyze.

Example output:

node 1 TRACE [lightning::ln::channelmanager:9524]       d9d065 Handling channel resumption with no RAA, no commitment update, 0 pending forwards, 0 pending update_add_htlcs, not broadcasting funding, without channel ready, without announcement, without tx_signatures, without tx_abort
node 1 TRACE [lightning::ln::channelmanager:14047]             Handling event PaymentPathSuccessful { payment_id: d4f97f7cfedd3724f15a7b401a4b12987fa391d1a9511ab4e3bf9dd9b5c4b082, payment_hash: Some(72cd6e8422c407fb6d098690f1130b7ded7ec2f7f5e1d30bd9d521f015363793), path: Path { hops: [RouteHop { pubkey: PublicKey(ce1dc610d880181464ae9a76568387c1fd3839d8af69f74012d241f33d2e8f88c4e526dbe59946cf190e949a2c5f92bafcccce5aa9708d2455d18231162afeb5), node_features: [0, 65, 2, 0, 0, 0, 0, 0], short_channel_id: 12094627971072, channel_features: [], fee_msat: 100000, cltv_expiry_delta: 70, maybe_announced_channel: true }], blinded_tail: None }, hold_times: [0] }...
node 1 TRACE [lightning::ln::channelmanager:14047]             Done handling event, result: Ok(())
node 0 TRACE [lightning::chain::chainmonitor:1355]      ae3367 Got new ChannelMonitor
node 0 INFO [lightning::chain::chainmonitor:1365]       ae3367 Persistence of new ChannelMonitor for completed
node 0 TRACE [lightning::chain::channelmonitor:2169]    ae3367 Registering funding outpoint 4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae:0 with the filter to monitor confirmations
node 0 TRACE [lightning::chain::channelmonitor:2177]    ae3367 Registering outpoint 4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae:0 with the filter to monitor spend
node 0 TRACE [lightning::chain::channelmonitor:2177]    ae3367 Registering outpoint 2cfeb0ada120458f8c86a42e3db280804fd2f2349c9d7eea5a7e9b9b7de9257f:0 with the filter to monitor spend
node 1 INFO [lightning::ln::channelmanager:16917]       d9d065 Successfully loaded at update_id 10 against monitor at update id 10 with 0 blocked updates
node 1 TRACE [lightning::chain::chainmonitor:1355]      ae3367 Got new ChannelMonitor
node 1 INFO [lightning::chain::chainmonitor:1365]       ae3367 Persistence of new ChannelMonitor for completed
node 1 TRACE [lightning::chain::channelmonitor:2169]    ae3367 Registering funding outpoint 4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae:0 with the filter to monitor confirmations
node 1 TRACE [lightning::chain::channelmonitor:2177]    ae3367 Registering outpoint 2cfeb0ada120458f8c86a42e3db280804fd2f2349c9d7eea5a7e9b9b7de9257f:0 with the filter to monitor spend

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Nov 11, 2025

👋 Thanks for assigning @TheBlueMatt 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.

@joostjager joostjager force-pushed the chan-logging branch 2 times, most recently from 5bae991 to bf104c0 Compare November 11, 2025 13:11
@joostjager joostjager marked this pull request as ready for review November 11, 2025 13:45
let s = format!("{:<55} {}", context, record.args);
let chan_id = record.channel_id.map(|id| format!("{}", id));
let chan_str = chan_id.as_deref().and_then(|s| s.get(..6)).unwrap_or("");
let s = format!("{:<55} {:<6} {}", context, chan_str, record.args);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than just updating the test logger, let's instead maybe add a Display implementation for Record that includes all the relevant information? After we do that we'll need to update the one in fuzzing and IMO the docs on the logger to make clear that we intend to not include redundant information in the human-readable part of the log record (and that they absolutely need to include it if they want useful logs).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Display added and docs updated.

As a preparatory step for unifying test log output.
Makes sure that 4 and 5 character log levels line up.
Now that we have Display implemented on Record, the various
test logger implementations can make use of that.
Previously, log messages often included the channel ID both in the
message text and in the structured `channel_id` field. This led to
redundant information and made it difficult to quickly identify which
log lines pertain to a given channel, as the ID could appear in
different positions or sometimes not at all.

This change removes the channel ID from the message in all cases where
it is already present in the structured field. A test run was used to
verify that the structured field always appeared in these log calls.
Some exceptions remain—for example, calls where the structured field
contains a temporary channel ID and the message contains the final ID
were left unchanged.
@joostjager joostjager force-pushed the chan-logging branch 2 times, most recently from 44dec3f to 2f6b50a Compare November 12, 2025 08:13
@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 97.66082% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.32%. Comparing base (cbbda61) to head (2f6b50a).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channel.rs 95.34% 2 Missing ⚠️
lightning/src/ln/htlc_reserve_unit_tests.rs 75.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4217   +/-   ##
=======================================
  Coverage   89.31%   89.32%           
=======================================
  Files         180      180           
  Lines      138055   138129   +74     
  Branches   138055   138129   +74     
=======================================
+ Hits       123309   123384   +75     
+ Misses      12142    12134    -8     
- Partials     2604     2611    +7     
Flag Coverage Δ
fuzzing 33.63% <45.16%> (+0.05%) ⬆️
tests 88.71% <97.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Since most log messages no longer include the channel ID in their text,
this commit updates the test logger to output the structured channel ID
instead. The ID is truncated for readability.
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.

3 participants