New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure LogPrintf strings are line-terminated #6497

Merged
merged 1 commit into from Aug 3, 2015

Conversation

Projects
None yet
5 participants
@laanwj
Member

laanwj commented Jul 31, 2015

Fix the cases where LogPrint[f] was accidentally called without line terminator, which resulted in concatenated log lines.

(see e.g. #6492)

@laanwj laanwj added the Docs label Jul 31, 2015

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jul 31, 2015

Member

ACK

Member

sipa commented Jul 31, 2015

ACK

}
LogPrint("estimatefee", "\n");

This comment has been minimized.

@morcos

morcos Jul 31, 2015

Member

It might be ugly, but it was working correctly before right? This will cause extra new lines I think, because NewTx above prints a new line. I guess we could just remove it from there. This may be a case of too much debugging, I'm not sure if we want all these anyway....

@morcos

morcos Jul 31, 2015

Member

It might be ugly, but it was working correctly before right? This will cause extra new lines I think, because NewTx above prints a new line. I guess we could just remove it from there. This may be a case of too much debugging, I'm not sure if we want all these anyway....

This comment has been minimized.

@laanwj

laanwj Aug 3, 2015

Member

Original code:

LogPrint("estimatefee", "Blockpolicy mempool tx %s ", hash.ToString().substr(0,10));
 // Record this as a priority estimate
if (entry.GetFee() == 0 || isPriDataPoint(feeRate, curPri)) {
...
}
// Record this as a fee estimate
else if (isFeeDataPoint(feeRate, curPri)) {
...
}
else {
    LogPrint("estimatefee", "not adding\n");
}

So the line will not be terminated unless the if() condition falls through.

But if you insist I'll remove this change...

@laanwj

laanwj Aug 3, 2015

Member

Original code:

LogPrint("estimatefee", "Blockpolicy mempool tx %s ", hash.ToString().substr(0,10));
 // Record this as a priority estimate
if (entry.GetFee() == 0 || isPriDataPoint(feeRate, curPri)) {
...
}
// Record this as a fee estimate
else if (isFeeDataPoint(feeRate, curPri)) {
...
}
else {
    LogPrint("estimatefee", "not adding\n");
}

So the line will not be terminated unless the if() condition falls through.

But if you insist I'll remove this change...

This comment has been minimized.

@morcos

morcos Aug 3, 2015

Member

I apologize for the ugly code again, but in the if and else if, feeStats and priStats both call NewTx respectively. NewTx adds a new line. I'd suggest leaving your change, but removing the new line in the LogPrint call in NewTx. Or, removing all the LogPrint lines altogether, what are your thoughts about the level of debugging? I found this useful in writing this code and for certain modifications it would be also valuable, but perhaps doesn't have much everyday value. I'm running into the same questions in the mempool limiting code where debugging the various failures is valuable when working on the code but perhaps not when its finished until someone wants to change it.

@morcos

morcos Aug 3, 2015

Member

I apologize for the ugly code again, but in the if and else if, feeStats and priStats both call NewTx respectively. NewTx adds a new line. I'd suggest leaving your change, but removing the new line in the LogPrint call in NewTx. Or, removing all the LogPrint lines altogether, what are your thoughts about the level of debugging? I found this useful in writing this code and for certain modifications it would be also valuable, but perhaps doesn't have much everyday value. I'm running into the same questions in the mempool limiting code where debugging the various failures is valuable when working on the code but perhaps not when its finished until someone wants to change it.

This comment has been minimized.

@laanwj

laanwj Aug 3, 2015

Member

OK, will do that.
This is optional debugging, so I think having it in the first place is fine. It can be useful if someone wants to troubleshoot the fee estimation, which I'm sure has to happen at some point.

@laanwj

laanwj Aug 3, 2015

Member

OK, will do that.
This is optional debugging, so I think having it in the first place is fine. It can be useful if someone wants to troubleshoot the fee estimation, which I'm sure has to happen at some point.

@jgarzik

This comment has been minimized.

Show comment
Hide comment
@jgarzik

jgarzik Aug 1, 2015

Contributor

ACK though agree @morcos has a point

Contributor

jgarzik commented Aug 1, 2015

ACK though agree @morcos has a point

@Diapolo

This comment has been minimized.

Show comment
Hide comment
@Diapolo

Diapolo Aug 3, 2015

utACK for trivial-branch

Diapolo commented Aug 3, 2015

utACK for trivial-branch

Make sure LogPrintf strings are line-terminated
Fix the cases where LogPrint[f] was accidentally called without line
terminator, which resulted in concatenated log lines.

(see e.g. #6492)
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Aug 3, 2015

Member

Ok, updated for @morcos' comment

Member

laanwj commented Aug 3, 2015

Ok, updated for @morcos' comment

@laanwj laanwj merged commit f18b8ec into bitcoin:master Aug 3, 2015

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

laanwj added a commit that referenced this pull request Aug 3, 2015

Merge pull request #6497
f18b8ec Make sure LogPrintf strings are line-terminated (Wladimir J. van der Laan)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment