net/log: standardize peer+addr log formatting via LogPeer #34389

pull l0rinc wants to merge 4 commits into bitcoin:master from l0rinc:l0rinc/log-peer-formatting changing 9 files +61 −47
  1. l0rinc commented at 12:09 pm on January 23, 2026: contributor

    This is an alternative to #34293, but aims to address the remaining logging inconsistencies more broadly. It extends the example fixed there to every instance, restores the original separator behavior, applies it consistently via a single helper, and adds tests for logips (covering both current and new behavior).

    Problem

    After #28521 centralized peer address logging into CNode::LogIP(), the original comma separator before peeraddr= was lost, resulting in inconsistent formatting across net (and recent private broadcast) logs. Some lines also had double spaces, empty fields, or mismatched format specifiers.

    Fix

    Introduces CNode::LogPeer(bool) which always emits peer=<id> and, when -logips=1, appends , peeraddr=<addr>. This eliminates hand-rolled separators and makes peer identification predictable. Minor issues (double spaces, empty placeholders, format specifiers) are fixed along the way in separate commits.

    Reproducer

    Run with -debug=net -logips=1 and observe peer log lines now show peer=<id>, peeraddr=<addr> (comma-separated). The new assertion in feature_logging.py automates this check.

  2. log: show placeholders for missing peer fields
    Avoid logging an empty field when peer subversion or collision entry is missing.
    dc9f572e8e
  3. log: fix minor formatting in debug logs
    Tidy a few debug log strings to avoid double spaces, concatenated status words, and mismatched format specifiers.
    e3b3b2b0f0
  4. test: add pre-`LogPeer` net log assertion
    Assert net log output contains `peer=... peeraddr=...` before the comma change.
    129374a6aa
  5. net: format peer+addr logs with `LogPeer`
    Use `LogPeer` for peer id plus optional `peeraddr`, separated with a comma.
    
    Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
    d515f7c8d5
  6. DrahtBot commented at 12:09 pm on January 23, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34389.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34293 (Bugfix: net_processing: Restore missing comma between peer and peeraddr in “receive version message” and “New ___ peer connected” by luke-jr)
    • #34271 (net_processing: make m_tx_for_private_broadcast optional by vasild)
    • #34267 (net: avoid unconditional privatebroadcast logging (+ warn for debug logs) by l0rinc)
    • #34181 (refactor: [p2p] Make ProcessMessage private again, Use references when non-null by maflcko)
    • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-27 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me