Fix LogPrint to LogPrintf #8230
pull thelazier wants to merge 1 commits into bitcoin:0.12 from thelazier:patch-1 changing 1 files +1 −1-
thelazier commented at 5:47 pm on June 20, 2016: contributorPrinting Log without category defined should use LogPrintf
-
Fix LogPrint to LogPrintf
Printing Log without category defined should use LogPrintf
-
eduffield222 commented at 9:08 pm on June 20, 2016: noneutACK
-
pstratem commented at 9:14 pm on June 20, 2016: contributorutACK ba6194928a03a474b442744511da4c753441469d
-
laanwj commented at 8:08 am on June 21, 2016: member
utACK ba61949 Good catch! This mistake is all too easy to make, unfortunately.
At some point we either need to rename one of those functions, or create an automatic checker for Printf/LogPrintf arguments, or both.
-
laanwj added the label Docs and Output on Jun 21, 2016
-
laanwj added the label Bug on Jun 21, 2016
-
laanwj merged this on Jun 21, 2016
-
laanwj closed this on Jun 21, 2016
-
laanwj referenced this in commit f3eebcf515 on Jun 21, 2016
-
gmaxwell commented at 8:10 am on June 21, 2016: contributorI hate that this isn’t typesafe, what is this, PHP? :) … when I saw the ticket open I felt immediately stupid, sure than it must have been me that did this again. (posthumous utACK).
-
laanwj commented at 8:18 am on June 21, 2016: member
Eh, why is this merging into 0.12 though? Isn’t this a problem on master?
I hate that this isn’t typesafe, what is this, PHP? :) .
Well it was a step up from C’s printf - none of this will allow mangling values or corrupting memory. It is typesafe, e.g you don’t need size specifiers, it doesn’t matter if you use
%i
or%lli
etc. Worst-case, you get an exception if the number of arguments doesn’t match the number of%
. Or nothing is logged and you rub your head why. There would be logging methods that are more robust, e.g. C++/Qt style:0LogInfo() << ""; 1LogDebug("rpc") << "Invalid RPC call " << strMethod;
(tinyformat even uses this internally, but emulates C printf-isms because that was what was already in the code and this had the least impact)
Then again, there’s so much to do already, it’s never been urgent.
-
laanwj referenced this in commit bf9c70b100 on Jun 21, 2016
-
laanwj commented at 8:22 am on June 21, 2016: memberForward-ported to master as bf9c70b. (this is not how we usually work, please base your PR on master next time unless it’s a backport)
-
sipa commented at 8:24 am on June 21, 2016: memberChanging the debug category into an enum would also avoid type ambiguity (which arises from the fact that the format string and the debug category are both strings).
-
laanwj commented at 8:29 am on June 21, 2016: member
Changing the debug category into an enum would also avoid type ambiguity
That’s a neat idea, a problem with that is that it requires centralizing all the debug categories of the program in one place. That would be inimical to modularization.
Another option would be to create a DebugCategory type that is based on string, and only allow passing that as category argument.
0DebugCategory LOG_RPC("rpc"); 1... 2LogPrintf(LOG_RPC, "Invalid RPC call %s\n", strMethod);
-
thelazier deleted the branch on Jun 21, 2016
-
DrahtBot locked this on Sep 8, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC
More mirrored repositories can be found on mirror.b10c.me