-
Notifications
You must be signed in to change notification settings - Fork 38.7k
re-work -debug switch handling #3067
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
Conversation
|
Comments? |
src/main.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be in a if(fDebug) for a reason, for example because they'll otherwise slow down the path with formatting/argument computation overhead even though the message is not logged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, ProcessMessage() is for sure performance critical. Do you have a clean idea if it's then still possible to quickly check if -debug=net was one of the specified categories or do you suggest to supply just a fDebug check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest just a fDebug check there.
If any kind of debugging is enabled, performance becomes less of an issue.
|
Updated:
|
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this -debugnet check needs to go first, so fDebug gets set correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, does -debug not imply all debug categories, so also fDebug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fDebug (as least how it's used in the code everywhere, for example in LogPrint) means any debug category is enabled, not all.
From the help message I understand that -debug (or -debug=1) implies all debug categories, but there was no special handling for that anywhere. That's changed by this pull.
|
I don't think I like the "-debug means -debug=all". I run with debug=1 in my bitcoin.conf, and will add temporary LogPrintf() statements as I develop code (and will remove them or change them to LogPrint("category"...) before pull-requesting). Just like I used to add printf() statements during development that I'd remove. If -debug means "print everything", then that doesn't work-- my log messages will get lost in the blizzard of messages. I suppose I could switch to -debug=temp and always LogPrint("temp", ...), but that's more typing and I'm lazy. |
|
@gavinandresen So what would you like -debug to mean then? |
|
-debug is the same as -debug= which has empty-string for the category. So Logprintf equals Logprint("",...) etc. Gavin Andresen On Oct 12, 2013, at 7:55 AM, Pieter Wuille [email protected] wrote:
|
|
I understand how logging with an empty category can be useful for temporary debugging, but from a user/external developer viewpoint, is it logical behavior? In any case I'd be fine with -debug=all as well instead of -debug to enable all categories. But there needs to be a way (and clearly documented in the help message). |
|
I agree with @laanwj here - having a "" debug category seems counter-intuitive. |
|
@sipa @laanwj @gavinandresen Using Perhaps we should re-work |
|
@Diapolo: -debug and -debug= are the same. They both will set mapArgs["-debug"]=std::string("") Changing that so -debug and -debug= sets mapArgs["-debug"] to two different things is likely to break things in unexpected ways. EDIT: just realized I'm probably misreading, and you mean -debug being different from -debug=<some_category>. Ok, I can live with -debug meaning -debug=all. I'll just set my default to -debug=none to get the default behavior I want. |
|
Sounds good to me. Related, but outside of this pullreq: I've been wondering whether categories shouldn't just correspond to threads, and indeed, whether we shouldn't just print them by default. Also, do we really worry enough to make -logtimestamps non-default anymore? |
|
@gavinandresen: when learning a codebase or trying to find a problem in an otherwise unknown codebase I usually find it useful to enable all debug information, to get some idea what it is doing. It's of more limited usability once you have a better idea what you're looking for. |
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could need some help for the help message :).
|
@sipa @laanwj @gavinandresen I added some suggestions from above and as I wrote earlier, this is achieved now: Using It would be still fine, if we could add category in front of the log entries e.g. |
|
@sipa Agreed, |
|
@gavinandresen @sipa @laanwj |
src/util.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work, this will only go into the if if categories.size() == 1. Something like this is easier to read, and does the length check before indexing into the array:
if (!(categories.size() == 1 && (categories[0]=="" || categories[0] =="1")))
Or even better
bool allCategories = (categories.size() == 1) && (categories[0]=="" || categories[0] =="1");
if(!allCategories)
{
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should happen if user says: -debug=net -debug ?
I think you want:
bool allCategories = categories.count("");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavinandresen agreed
|
Great suggestions, re-working... |
|
Updated:
I hope this is now just a final review! |
|
Failure because of the json-pull... |
|
Updated and removed an unneeded |
|
Can I get some ACKs :)? |
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's perhaps better to split this line in two, to cover the -debug=category and -debug cases.
|
ACK apart from the nit above. |
|
@sipa I reworked the help-message for -debug once more, it reads now: Bitcoin-Qt: |
|
@Diapolo It's stil an extremely long line :) |
|
@sipa Like this? Output debugging information for category. Output all possible debugging information if category is not set. Category can be addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net. Or feel free to just suggest a string, so we can merge this :). |
|
New string with new-lines :-D. bitcoind Output debugging information for category. Category can be addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net. Output all possible debugging information if category is not set. Bitcoin-Qt Output debugging information for category. Category can be addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net or qt. Output all possible debugging information if category is not set. |
|
I hope @BitcoinPullTester is now happy again and @gavinandresen or @sipa can give a final ACK. |
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer to see this output line split up. I think explaining -debug=category and -debug separate is much more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change that, thanks for your time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this?
-debug=category Output debugging information (default: 0, supplying category is optional) If category is not supplied, output all debugging information. category can be: addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net, qt.
- re-work -debug help message text - make -debug log every debugging information again (even all categories) - remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that check is done in LogPrintf() when category is != NULL (true for all LogPrint() calls - remove fDebug ONLY in code which is NOT performance-critical - harmonize addrman category name - deprecate -debugnet usage, should be used via -debug=net and remove the corresponding global
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/3b570559f8d39a5d4cffd01b8091c3133f7750dc for binaries and test log. |
|
ACK |
re-work -debug switch handling
check is done in LogPrintf() when category is != NULL (true for all
LogPrint() calls
corresponding global