mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-09 15:18:03 +02:00
Merge bitcoin/bitcoin#34389: net/log: standardize peer+addr log formatting via LogPeer
22335474d7net: format peer+addr logs with `LogPeer` (Lőrinc)e55ea534f7test: add pre-`LogPeer` net log assertion (Lőrinc)736b17c0f0log: fix minor formatting in debug logs (Lőrinc)9cf82bed32log: show placeholders for missing peer fields (Lőrinc) Pull request description: 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. ACKs for top commit: naiyoma: ACK22335474d7vasild: ACK22335474d7sedited: ACK22335474d7Tree-SHA512: 562262a58c3042f139099ff4c41e3fc6a97505fe9603c2bf700a97fd0aa052954b47c14da0e50c1fc311db1ae6c04e6a92156c9b85e25c777a637b7766c1dafe
This commit is contained in:
@@ -1969,12 +1969,12 @@ void Chainstate::InvalidChainFound(CBlockIndex* pindexNew)
|
||||
m_chainman.RecalculateBestHeader();
|
||||
}
|
||||
|
||||
LogInfo("%s: invalid block=%s height=%d log2_work=%f date=%s\n", __func__,
|
||||
LogInfo("%s: invalid block=%s height=%d log2_work=%f date=%s", __func__,
|
||||
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime()));
|
||||
CBlockIndex *tip = m_chain.Tip();
|
||||
assert (tip);
|
||||
LogInfo("%s: current best=%s height=%d log2_work=%f date=%s\n", __func__,
|
||||
LogInfo("%s: current best=%s height=%d log2_work=%f date=%s", __func__,
|
||||
tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0),
|
||||
FormatISO8601DateTime(tip->GetBlockTime()));
|
||||
CheckForkWarningConditions();
|
||||
|
||||
Reference in New Issue
Block a user