While debugging unexpected disconnections, possibly related to #28331, I found some additional [net] logging to be useful.
All cases where we disconnect now come with a log message that has the word disconnecting:
- all calls to CloseSocketDisconnect()logdisconnecting peer=…
- wherever we set pnode->fDisconnect = true;
- for all InactivityCheckcases (which in turn setsfDisconnect)
- replaces “dropping” with “disconnecting” in Network not active, dropping peer=…
A few exceptions are listed here: #28521 (review)
I changed CloseSocketDisconnect() to no longer log disconnecting, and instead have all the call sites do so.
This PR introduces two helper functions on CNode: DisconnectMsg and LogIP. The second and third commit use these helpers in net_processing.cpp so these disconnect messages are more consistent now (e.g. some didn’t log the IP). No new messages are added there though.
The LogIP() helper is rarely used outside of a disconnect event, but it’s available for future use.
Any LogPrint this PR touches is replaced with LogDebug (superseded by #30750), and every LogPrintf  with LogInfo.