Skip to content

Commit

Permalink
Merge pull request #520 from tcatm/less-logging
Browse files Browse the repository at this point in the history
log low-level network messages only when fDebug is set
  • Loading branch information
Nils Schneider committed Sep 19, 2011
2 parents 7337b34 + e674680 commit 2d294e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1744,9 +1744,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
static map<unsigned int, vector<unsigned char> > mapReuseKey;
RandAddSeedPerfmon();
if (fDebug)
if (fDebug) {
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size());
printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size());
}
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
printf("dropmessagestest DROPPING RECV MESSAGE\n");
Expand Down Expand Up @@ -1934,7 +1935,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pfrom->AddInventoryKnown(inv);

bool fAlreadyHave = AlreadyHave(txdb, inv);
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
if (fDebug)
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");

if (!fAlreadyHave)
pfrom->AskFor(inv);
Expand Down
14 changes: 9 additions & 5 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ class CNode
nHeaderStart = vSend.size();
vSend << CMessageHeader(pszCommand, 0);
nMessageStart = vSend.size();
if (fDebug)
if (fDebug) {
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("sending: %s ", pszCommand);
printf("sending: %s ", pszCommand);
}
}

void AbortMessage()
Expand All @@ -295,7 +296,9 @@ class CNode
nHeaderStart = -1;
nMessageStart = -1;
cs_vSend.Leave();
printf("(aborted)\n");

if (fDebug)
printf("(aborted)\n");
}

void EndMessage()
Expand Down Expand Up @@ -324,8 +327,9 @@ class CNode
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
}

printf("(%d bytes) ", nSize);
printf("\n");
if (fDebug) {
printf("(%d bytes)\n", nSize);
}

nHeaderStart = -1;
nMessageStart = -1;
Expand Down

0 comments on commit 2d294e0

Please sign in to comment.