aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNils Schneider <nils@nilsschneider.net>2011-09-19 12:19:15 -0700
committerNils Schneider <nils@nilsschneider.net>2011-09-19 12:19:15 -0700
commit2d294e080c192cbea5ac0e331a3aab695cee37c8 (patch)
treef8ddcddad11b3f880b2d3bd855a867ea19bca212 /src
parent7337b343cdc73bff7d3125d56e00189cd93c9148 (diff)
parente674680ddd17382e0605472385e1bd5d0cf4e502 (diff)
Merge pull request #520 from tcatm/less-logging
log low-level network messages only when fDebug is set
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
-rw-r--r--src/net.h14
2 files changed, 14 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 5b159fe415..6a3bacc78e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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");
@@ -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);
diff --git a/src/net.h b/src/net.h
index efac1f452a..0026e402c2 100644
--- a/src/net.h
+++ b/src/net.h
@@ -282,9 +282,10 @@ public:
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()
@@ -295,7 +296,9 @@ public:
nHeaderStart = -1;
nMessageStart = -1;
cs_vSend.Leave();
- printf("(aborted)\n");
+
+ if (fDebug)
+ printf("(aborted)\n");
}
void EndMessage()
@@ -324,8 +327,9 @@ public:
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;