Skip to content

Conversation

@Diapolo
Copy link

@Diapolo Diapolo commented Oct 8, 2013

  • 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

@Diapolo
Copy link
Author

Diapolo commented Oct 10, 2013

Comments?

src/main.cpp Outdated
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

@Diapolo
Copy link
Author

Diapolo commented Oct 11, 2013

Updated:

  • remove fDebug ONLY in code which is NOT performance-critical

src/init.cpp Outdated
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

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.

@gavinandresen
Copy link
Contributor

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.

@sipa
Copy link
Member

sipa commented Oct 11, 2013

@gavinandresen So what would you like -debug to mean then?

@gavinandresen
Copy link
Contributor

-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:

@gavinandresen So what would you like -debug to mean then?


Reply to this email directly or view it on GitHub.

@laanwj
Copy link
Member

laanwj commented Oct 12, 2013

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?
What would you expect plain -debug to do on a package that you don't know deeply yet and are trying to debug?

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).

@sipa
Copy link
Member

sipa commented Oct 12, 2013

I agree with @laanwj here - having a "" debug category seems counter-intuitive.

@Diapolo
Copy link
Author

Diapolo commented Oct 16, 2013

@sipa @laanwj @gavinandresen
I'll summarize, what I think should be default behaviour (I don't say the pull is currently doing this already ^^):

Using -debug sets fDebug and we display ALL categories (LogPrint()).
Using -debug=<category> sets fDebug and we display ONLY the speciefied categories.

Perhaps we should re-work LogPrint() to prepend the category in the log-entry, as this will make searching the log MUCH easier!

@gavinandresen
Copy link
Contributor

@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>.
EDIT2: aha! Bitten by github removing stuff in <> ....

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.

@sipa
Copy link
Member

sipa commented Oct 16, 2013

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?

@laanwj
Copy link
Member

laanwj commented Oct 16, 2013

@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
Copy link
Author

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 :).

@Diapolo
Copy link
Author

Diapolo commented Oct 17, 2013

@sipa @laanwj @gavinandresen
Can you take another look?

I added some suggestions from above and as I wrote earlier, this is achieved now:

Using -debug or -debug=1 sets fDebug and we display ALL categories (all LogPrint()).
Using -debug=<category> sets fDebug and we display ONLY the speciefied categories (only LogPrint(<category>)).

It would be still fine, if we could add category in front of the log entries e.g. [net] blabla happened.

@Diapolo
Copy link
Author

Diapolo commented Oct 17, 2013

@sipa Agreed, -logtimestamps should be default, as it's much more readable IMO.

@Diapolo
Copy link
Author

Diapolo commented Oct 22, 2013

@gavinandresen @sipa @laanwj
Rebased, fixed a merge-conflict. Can I get some final ACKs or futher comments?

src/util.cpp Outdated
Copy link
Member

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)
{
....

Copy link
Contributor

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("");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Diapolo
Copy link
Author

Diapolo commented Oct 22, 2013

Great suggestions, re-working...

@Diapolo
Copy link
Author

Diapolo commented Oct 22, 2013

Updated:

  • help message
  • special-case -debug=0/-nodebug
  • replace my checks with generic checks (thanks @laanwj and @gavinandresen)

-debug overrides -debug=<category> and -debug=0 or -nodebug override all others!

I hope this is now just a final review!

@Diapolo
Copy link
Author

Diapolo commented Oct 22, 2013

Failure because of the json-pull...

@Diapolo
Copy link
Author

Diapolo commented Oct 24, 2013

Updated and removed an unneeded \n in InitWarning().

@Diapolo
Copy link
Author

Diapolo commented Oct 26, 2013

Can I get some ACKs :)?

src/init.cpp Outdated
Copy link
Member

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.

@sipa
Copy link
Member

sipa commented Oct 26, 2013

ACK apart from the nit above.

@Diapolo
Copy link
Author

Diapolo commented Oct 26, 2013

@sipa I reworked the help-message for -debug once more, it reads now:
bitcoind:
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.

Bitcoin-Qt:
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 qt.

@sipa
Copy link
Member

sipa commented Oct 26, 2013

@Diapolo It's stil an extremely long line :)

@Diapolo
Copy link
Author

Diapolo commented Oct 27, 2013

@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 :).

@Diapolo
Copy link
Author

Diapolo commented Oct 28, 2013

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.

@Diapolo
Copy link
Author

Diapolo commented Oct 30, 2013

I hope @BitcoinPullTester is now happy again and @gavinandresen or @sipa can give a final ACK.

src/init.cpp Outdated
Copy link
Member

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.

Copy link
Author

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.

Copy link
Author

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
@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/3b570559f8d39a5d4cffd01b8091c3133f7750dc for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@sipa
Copy link
Member

sipa commented Oct 30, 2013

ACK

gavinandresen added a commit that referenced this pull request Oct 30, 2013
re-work -debug switch handling
@gavinandresen gavinandresen merged commit ef4b518 into bitcoin:master Oct 30, 2013
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Apr 8, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants